当前位置: 首页 > 工具软件 > kube-bench > 使用案例 >

kubelet

燕正德
2023-12-01
[root@k8s-node31-172-23-210-31 ~]# cat /usr/lib/systemd/system/kubelet.service 
[Unit]
Description=Kubernetes Kubelet Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/var/lib/kubelet
ExecStart=/usr/bin/kubelet \
       --address=172.23.210.31 \
       --hostname-override=172.23.210.31 \
       --pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest \
       --experimental-bootstrap-kubeconfig=/etc/kubernetes/bootstrap.kubeconfig \
       --kubeconfig=/etc/kubernetes/kubelet.kubeconfig \
       --cert-dir=/etc/kubernetes/ssl \
       --container-runtime=docker \
       --cluster-dns=172.33.0.254 \
       --cluster-domain=cluster.local \
       --hairpin-mode promiscuous-bridge \
       --allow-privileged=true \
       --runtime-cgroups=/systemd/system.slice \
       --kubelet-cgroups=/systemd/system.slice \
       --serialize-image-pulls=false \
       --register-node=true \
       --logtostderr=true \
       --cgroup-driver=cgroupfs  \
       --v=0
Restart=on-failure
[Install]
WantedBy=multi-user.target

基础信息补充

Deployment 示例,它创建了一个 ReplicaSet 来启动3个 nginx pod
kubectl create -f https://kubernetes.io/docs/user-guide/nginx-deployment.yaml --record

查询结果
kubectl get rc  
kubectl get pods
kubectl get pods -o wide

kubectl get services

kubectl get deployments

kubectl get rs

kubectl get pods --show-labels

kubectl describe deployment

扩容
kubectl scale deployment nginx-deployment --replicas 10

如果集群支持 horizontal pod autoscaling 的话,还可以为Deployment设置自动扩展:
kubectl autoscale deployment nginx-deployment --min=10 --max=15 --cpu-percent=80

更新镜像
kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1

回滚
kubectl rollout undo deployment/nginx-deployment

对pod中的容器执行命令
kubectl exec <pod-name> date
kubectl exec <pod-name> -c <container-name> date
kubectl exec -ti <pod-name> /bin/bash

kubectl logs - 打印pod中的容器的日志
kubectl logs <pod-name>
kubectl logs -f <pod-name>
 类似资料: