I want to see the Solution
-
Run the below Command for Solution
ETCDCTL_API=3 etcdctl snapshot save --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key --endpoints=127.0.0.1:2379 /tmp/etcd-backup.db
-
Run the below Command for Solution
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: elephant name: elephant spec: containers: - image: redis name: elephant resources: requests: cpu: "1" memory: "200Mi" dnsPolicy: ClusterFirst restartPolicy: Always status: {}
-
Run the below Command for Solution
apiVersion: v1 kind: Pod metadata: creationTimestamp: null name: super-user-pod spec: containers: - image: busybox:1.28 name: super-user-pod command: ["sleep", "4800"] securityContext: capabilities: add: ["SYS_TIME"]
-
Run the below Command for Solution
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Mi
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: use-pv name: use-pv spec: containers: - image: nginx name: use-pv volumeMounts: - mountPath: "/data" name: mypod volumes: - name: mypod persistentVolumeClaim: claimName: my-pvc
-
Run the below Command for Solution
For Kubernetes Version <=1.17
kubectl run nginx-deploy --image=nginx:1.16 --replicas=1 --record kubectl rollout history deployment nginx-deploy kubectl set image deployment/nginx-deploy nginx-deploy=nginx=1.17 --record kubectl rollout history deployment nginx-deploy
For Kubernetes Version >1.17
kubectl create deployment nginx-deploy --image=nginx:1.16 --dry-run -o yaml > deploy.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deploy spec: replicas: 2 selector: matchLabels: app: nginx-deploy strategy: {} template: metadata: creationTimestamp: null labels: app: nginx-deploy spec: containers: - image: nginx:1.16 name: nginx
kubectl create -f deploy.yaml --record kubectl rollout history deployment nginx-deploy kubectl set image deployment/nginx-deploy nginx-deploy=nginx=1.17 --record kubectl rollout history deployment nginx-deploy
-
Run the below Command for Solution
apiVersion: certificates.k8s.io/v1beta1 kind: CertificateSigningRequest metadata: name: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b0dpcm8vamVxK2E2aFFLK1VKNHB6SDdNM04 3TW9oT2FvU2VjOEQKTmtnSThYREowbGNYWkJLZXZZZVd3UFhZZzh1cTdkQ0YKLS0tLS1FTkQgQ0VSVElGSUNBVEUgUkVRVUVTVC0tLS0tCg== usages: - digital signature - key encipherment - server auth
kubectl create role developer --resource=pods --verb=create,list,get,update,delete --namespace=development kubectl create rolebinding developer-role-binding --role=developer --user=john --namespace=development kubectl auth can-i update pods --as=john --namespace=development
-
Run the below Command for Solution
kubectl run nginx-resolver --image=nginx kubectl expose pod nginx-resolver --name=nginx-resolver-service --port=80 --tartget-port=80 --type=ClusterIP kubectl run test-nslookup --image=busybox:1.28 --rm -it -- nslookup nginx-resolver-service kubectl run test-nslookup --image=busybox:1.28 --rm -it -- nslookup nginx-resolver-service > /root/nginx.svc Get the IP of the nginx-resolver pod and replace the dots(.) with hyphon(-) which will be used below. kubectl get pod nginx-resolver -o wide kubectl run test-nslookup --image=busybox:1.28 --rm -it -- nslookup <P-O-D-I-P.default.pod> > /root/nginx.pod
-
Run the below Command for Solution
kubectl run static nginx-critical --image=nginx --dry-run=client -o yaml > static.yaml cat static.yml - Copy the contents of this file. kubectl get nodes -o wide ssh node01 OR ssh <IP of node01> Check if static-pod directory is present which is /etc/kubernetes/manifests if not then create it. mkdir -p /etc/kubernetes/manifests Paste the contents of the file(static.yaml) copied in the first step to file nginx-critical.yaml. Move/copy the nginx-critical.yaml.yaml to /etc/kubernetes/manifests cp nginx-critical.yaml /etc/kubernetes/manifests Go back to master node kubectl get pods