Question : The Nautilus DevOps team has started practicing some pods, and services deployment on Kubernetes platform, as they are planning to migrate most of their applications on Kubernetes. Recently one of the team members has been assigned a task to create a deploymnt as per details mentioned below:
Create a deployment named httpd to deploy the application httpd using the image httpd:latest (remember to mention the tag as well)
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.
Please Note :- Perform the below commands based on your question server, user name & other details might differ . So please read task carefully before executing. All the Best 👍
Solution:
1. At first kubectl utility configure and working from jump server, run below commands
thor@jump_host /$ kubectl get deploy No resources found in default namespace. thor@jump_host /$ thor@jump_host /$ kubectl get namespace NAME STATUS AGE default Active 58m kube-node-lease Active 58m kube-public Active 58m kube-system Active 58m thor@jump_host /$ |
2. Create deploy & and run image as per the task request
thor@jump_host /$ kubectl create deploy httpd --image httpd:latest deployment.apps/httpd created thor@jump_host /$ |
3. Validate the task by running below commands
thor@jump_host /$ kubectl get deploy NAME READY UP-TO-DATE AVAILABLE AGE httpd 0/1 1 0 19s thor@jump_host /$ thor@jump_host /$ kubectl get pods NAME READY STATUS RESTARTS AGE httpd-84898796c-k2gzt 1/1 Running 0 76s thor@jump_host /$ thor@jump_host /$ kubectl describe pod httpd-84898796c-k2gzt Name: httpd-84898796c-k2gzt Namespace: default Priority: 0 Node: kodekloud-control-plane/172.17.0.2 Start Time: Wed, 19 Jan 2022 10:47:11 +0000 Labels: app=httpd pod-template-hash=84898796c Annotations: <none> Status: Running IP: 10.244.0.5 IPs: IP: 10.244.0.5 Controlled By: ReplicaSet/httpd-84898796c Containers: httpd: Container ID: containerd://fbb944a89707cc60ebaca0210ee051b9f5c892b518a2a880bc5b4a72d2bc7ab6 Image: httpd:latest Image ID: docker.io/library/httpd@sha256:0954cc1af252d824860b2c5dc0a10720af2b7a3d3435581ca788dff8480c7b32 Port: <none> Host Port: <none> State: Running Started: Wed, 19 Jan 2022 10:47:42 +0000 Ready: True Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-b9s7f (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: default-token-b9s7f: Type: Secret (a volume populated by a Secret) SecretName: default-token-b9s7f Optional: false QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 3m51s default-scheduler Successfully assigned default/httpd-84898796c-k2gzt to kodekloud-control-plane Normal Pulling 3m36s kubelet Pulling image "httpd:latest" Normal Pulled 3m21s kubelet Successfully pulled image "httpd:latest" in 15.194337287s Normal Created 3m21s kubelet Created container httpd Normal Started 3m20s kubelet Started container httpd thor@jump_host ~$ |
4. Click on Finish & Confirm to complete the task successful
Happy Learning!!!!
Apart from this if you need more clarity, I have made a tutorial video on this , please go through and share your comments. Like and share the knowledge
thor@jump_
0 Comments