Q1
①ckadというnamespaceを作成する
②以下の条件でPodを起動する
名前:CacheServer
使用イメージ:lfccncf/redis(タグ3.2)
公開ポート:6379
namespace:ckad
③Podの起動確認を行う
A1
①kubectl create nsによるnamespaceの作成
kubeuser@master01:~$ kubectl get ns NAME STATUS AGE blue Active 281d cadvisor Active 237d default Active 296d ingress-nginx Active 294d istio-system Active 71d kube-node-lease Active 296d kube-public Active 296d kube-system Active 296d kubernetes-dashboard Active 283d metallb-system Active 296d orange Active 281d kubeuser@master01:~$ kubectl create ns ckad namespace/ckad created kubeuser@master01:~$ kubectl get ns NAME STATUS AGE blue Active 281d cadvisor Active 237d ckad Active 3s default Active 296d ingress-nginx Active 294d istio-system Active 71d kube-node-lease Active 296d kube-public Active 296d kube-system Active 296d kubernetes-dashboard Active 283d metallb-system Active 296d orange Active 281d
②kubectl runによるPodの起動
kubeuser@master01:~$ kubectl run cacheserver --image=lfccncf/redis:3.2 --port=6379 -n ckad -o yaml --dry-r un=client > q1_pod.yaml kubeuser@master01:~$ cat q1_pod.yaml apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: cacheserver name: cacheserver namespace: ckad spec: containers: - image: lfccncf/redis:3.2 name: cacheserver ports: - containerPort: 6379 resources: {} dnsPolicy: ClusterFirst restartPolicy: Always status: {} kubeuser@master01:~$ kubectl apply -f q1_pod.yaml pod/cacheserver created
③kubectl get podsによるPodの起動確認
kubeuser@master01:~$ kubectl get pods -n ckad NAME READY STATUS RESTARTS AGE cacheserver 0/1 ContainerCreating 0 6s kubeuser@master01:~$ kubectl get pods -n ckad -w NAME READY STATUS RESTARTS AGE cacheserver 0/1 ContainerCreating 0 11s cacheserver 1/1 Running 0 40s
おまけ:削除
kubeuser@master01:~$ kubectl delete pod cacheserver -n ckad --force Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. pod "cacheserver" force deleted kubeuser@master01:~$ kubectl get pods -n ckad No resources found in ckad namespace.
kubeuser@master01:~$ kubectl delete ns ckad namespace "ckad" deleted kubeuser@master01:~$ kubectl get ns NAME STATUS AGE blue Active 281d cadvisor Active 237d default Active 296d ingress-nginx Active 294d istio-system Active 71d kube-node-lease Active 296d kube-public Active 296d kube-system Active 296d kubernetes-dashboard Active 283d metallb-system Active 296d orange Active 281d