概述
K8s的最小资源单位pod
创建pod配置文件
apiVersion: v1 kind: Pod metadata: name: nginx labels: app: web spec: containers: - name: nginx image: nginx:1.13 ports: - containerPort: 80
创建
kubectl create -f nginx_pod.ymal
如果出现错误
Error from server (ServerTimeout): error when creating "nginx_pod.ymal": No API token found for service account "default", retry after the token is automatically created and added to the service account
需要修改文件
vim /etc/kubernetes/apiserver
删除当中的 serviceAccount 插件> KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota" > ``` > > * 查看状态
# 查看pod情况 kubectl get pod
# 查看分配节点 kubectl get pod -o wide # 查看指定pod详情 kubectl describe pod nginx
> 如果出现错误:
>
> Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)"
>
> 则修改 `vim /etc/kubernetes/kubelet` ,可以通过 `docker search pod-infrastructure` 来查看最优的安装源
>
> ```
> KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=docker.io/tianyebj/pod-infrastructure:latest"
> ```
>
* 修改Pod资源
```
kubectl edit pod nginx
```
>修改后自动生效
* 删除Pod
kubectl delete pod nginx # 强制删除 kubectl delete pod nginx --force --grace-period=0 ```