当前位置:网站首页>Tke accesses the cluster through kubectl in pod
Tke accesses the cluster through kubectl in pod
2022-06-24 03:11:00 【Nieweixing】
Now, all kinds of cloud vendors provide managed services k8s service , And there is a visual front end to access the resources in the cluster , Again tke The same is true of clusters , But as a k8s Users of , use kubectl To access the cluster is essential ,tke The console does not display all resource types , Like some custom crd You can only view it by command , And there is a console to check in time , Many big men are still used to command . However, the permissions on the cloud are generally strictly controlled , You may only have console permissions , You do not have permission to log in to the machine , Or your cluster does not have public network access enabled , Only intranet access , How to pass this time kubectl To access the cluster ?
Now let's go through tke Deploy a... Within the cluster kubectl Of pod, To access the cluster as a client apiserver, The premise is that you can operate on the console tke colony .
1. adopt configmap Mount cluster kubeconfig
1.1 The console gets kubeconfig
If you can operate the console tke The cluster describes the... Under your account kubeconfig There is authority , Access the basic information page of the cluster kubeconfig
1.2 Get clusters apiserver Internal visits ip Address
the reason being that kubectl In the cluster pod, So we went through apiserver Of cluserip Just visit , Get next default Under the namespace kubernetes This service Of clusterip, The port is 443.
1.3 establish configmap
Refer to the following modification yaml, adopt configmap Put our revised kubeconfig Mount to pod, What needs to be noted here is that the console will get Kubeconfig In file clusters.cluster.server Replace the field with https://<kubernetes svc Of clusterip>:443 that will do .
apiVersion: v1
data:
config: |-
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZ
server: https://172.16.0.1:443
name: cls-xxxx
contexts:
- context:
cluster: cls-xxxx
user: "xxxxx"
name: cls-xxxxx-xxxxx-context-default
current-context: cls-xxxx-xxxxx-context-default
kind: Config
preferences: {}
users:
- name: "xxxxxx"
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJU
client-key-data: LS0tLS1CRUdJTiBSU0EgUFJJVk
kind: ConfigMap
metadata:
name: config
namespace: tke-test
2. Deploy kubectl The workload
Here we deploy the workload , And mount the configmap, Give Way kubectl It can be read directly by default kubeconfig, because kubectl The image has no resident process , So here's a sleep As pod Resident process , visit pod I can't get up .
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: kubectl
qcloud-app: kubectl
name: kubectl
namespace: tke-test
spec:
replicas: 1
selector:
matchLabels:
k8s-app: kubectl
qcloud-app: kubectl
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
k8s-app: kubectl
qcloud-app: kubectl
spec:
containers:
- args:
- 3600d
command:
- sleep
image: mohamedltaief/kubctl-helm:latest
imagePullPolicy: Always
name: kubectl
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 250m
memory: 256Mi
securityContext:
privileged: false
volumeMounts:
- mountPath: /root/.kube/config
name: vol
subPath: config
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: qcloudregistrykey
restartPolicy: Always
volumes:
- configMap:
defaultMode: 420
name: config
name: vol3. Test access cluster
pod After successful startup , Sign in pod perform kubectl If the cluster information can be viewed, the access is successful .
边栏推荐
- Grpc: how do I start multiple ports?
- Permission maintenance topic: domain controller permission maintenance
- Why can't cloud games connect to the server? What if the cloud game fails to connect to the server?
- Tencent cloud launched its new 100g+ cloud server product!! Expect more than 400g+ in the future!
- Disk and file system (Simplified)
- Actual combat | how to use micro build low code to realize tolerance application
- What is the GPU usage for cloud desktops and servers? What can cloud desktop do?
- How to set up a cloud desktop server? Is there a charge for cloud desktop server setup?
- What port does the fortress machine use? What is the role of the fortress machine?
- What is the edge calculator force? What about the edge calculator?
猜你喜欢

2022-2028 global aircraft front wheel steering system industry research and trend analysis report

2022-2028 global pilot night vision goggle industry research and trend analysis report

2022-2028 global cancer biopsy instrument and kit industry research and trend analysis report

2022-2028 global indoor pressure monitor and environmental monitor industry research and trend analysis report

2022-2028 global aircraft wireless intercom system industry research and trend analysis report
![[summary of interview questions] zj5](/img/d8/ece82f8b2479adb948ba706f6f5039.jpg)
[summary of interview questions] zj5
![[51nod] 3395 n-bit gray code](/img/b5/2c072a11601de82cb92ade94672ecd.jpg)
[51nod] 3395 n-bit gray code
![[51nod] 3216 Awards](/img/94/fdb32434d1343040d711c76568b281.jpg)
[51nod] 3216 Awards

2022-2028 global marine wet exhaust hose industry research and trend analysis report

2022-2028 global portable two-way radio equipment industry research and trend analysis report
随机推荐
Tencent cloud CIF engineering effectiveness summit was successfully opened, and coding released a series of new products
Cp/rm/mv parameters
Use Charles to capture the package of the applet through the mobile agent
[hot] with a budget of only 100 yuan, how to build a 1-year web site on Tencent cloud??
Industry experts talk about "extortion virus": how does e-government build a moat?
The cost of on-site development of software talent outsourcing is higher than that of software project outsourcing. Why
Innovation or hype? Is low code a real artifact or a fake tuyere?
Is the cloud desktop server highly required for installation and configuration? Is cloud desktop easy to use?
Gigabyte was attacked by blackmail software, and the FBI banned the hacker organization Revil | global network security hotspot
What is the use of cloud desktop security server configuration? What should I do?
2022-2028 global anti counterfeiting label industry research and trend analysis report
How to register a trademark? What needs to be prepared?
2022-2028 global indoor pressure monitor and environmental monitor industry research and trend analysis report
Introduce the comparison of various distributed configuration centers? Which distributed configuration center is better?
What aspects does the intelligent identification system include? Is the technology of intelligent identification system mature now?
Why do cloud desktops use rack servers? Why choose cloud desktop?
The server size of the cloud desktop. The cloud desktop faces the server configuration requirements
11111dasfada and I grew the problem hot hot I hot vasser shares
JMeter script FAQs
2022-2028 global portable two-way radio equipment industry research and trend analysis report