环境说明
| IP | HOSTNAME | NOTE |
|---|
| 10.10.10.91 | CentOS7 | N/A |
环境搭建
安装kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
mv kubectl /usr/bin/kubectl
通过指定yaml文件创建pod
kubectl create -f busybox.yaml -n default # 在default namespace下创建pod
apiVersion: v1
kind: Pod
metadata:
name: busybox
spec:
containers:
- name: busybox
image: busybox:stable
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- while true; do sleep 30; done;

对指定container执行命令
kubectl exec -n default busybox -- cat /etc/passwd
