k8s 基本操作  ## 基本操作 ``` # 编辑配置文件 kubectl -n timatrix-test edit deployment/recvehicle-youtu-service # 获取所有节点 kubectl get pods -n timatrix-test # 描述部署情况 kubectl describe deployments/recvehicle-youtu-service -n timatrix-test # 获取daemonset节点 kubectl get daemonset -n timatrix-test # 查看当前pod信息 kubectl get po -n timatrix-test # 编辑deploy文件 kubectl edit deploy service-name -n timatrix-test # 删除deploy kubectl delete deploy service-name -n timatrix-test # 删除 -pod kubectl -n timatrix-algorithm --force --grace-period=0 delete pod xxxx # 查看logs kubectl logs pod-name -n timatrix-test # 删除pod kubectl delete pod pod-name # 进入容器 kubectl exec -it adaptor-1400-596c5566d-pd7jt -n timatrix-test -- /bin/bash ``` ## 导入导出服务 ```console # 导出配置(daemonset) kubectl get daemonset monitor-agent -n timatrix-test -oyaml --export > /tmp/deploy_monitor-agent_1553497150.yaml # 导出配置(普通) kubectl get deploy monitor-agent -n timatrix-test -oyaml --export > /tmp/deploy_monitor-agent_1553497150.yaml # 导出svc kubectl get svc monitor-agent -n timatrix-test -oyaml --export > /tmp/service_monitor-agent_1553497151.yaml ``` 在新机器应用配置 ```console kubectl -n timatrix-test apply -f /tmp/deploy_monitor-agent_1553497150.yaml ``` 导出configmap ```console kubectl get configmap monitor-agent -n timatrix-test -o yaml > /tmp/config_monitor-agent.yaml ``` ## 设置nodeport 有时,要在本机访问容器内的服务,在yaml设置nodeport,注意type: NodePort ``` spec: clusterIP: 172.29.255.83 externalTrafficPolicy: Cluster ports: - name: tcp-8080-8080 nodePort: 32683 port: 8080 protocol: TCP targetPort: 8080 selector: qcloud-app: task-manager sessionAffinity: None type: NodePort ``` 来自 大脸猫 写于 2019-03-08 11:25 -- 更新于2020-10-19 13:06 -- 2 条评论