I followed these steps but task failed. Please advise.
Task: Deploy Tomcat App on Kubernetes
Task Details
A new java-based application is ready to be deployed on a Kubernetes cluster. The development team had a meeting with the DevOps team share requirements and application scope. The team is ready to setup an application stack for it under their existing cluster. Below you can find the details for this:
Create a namespace named tomcat-namespace-devops.
Create a deployment for tomcat app which should be named tomcat-deployment-devops under the same namespace you created. Replicas count should be 1, the container should be named as tomcat-container-devops, its image should be Google Cloud console and its container port should be 8080.
Create a service for tomcat app which should be named as tomcat-service-devops under the same namespace you created. Service type should be NodePort. Port’s protocol should be TCP, port should be 80, targetPort should be 8080 and nodePort should be 32227.
Before clicking on Finish button please make sure the application is up and running.
You can use any labels as per your choice.
Note: The kubectl on jump_host has been configured to work with the kubernetes cluster.
1.At first kubectl utility configure and working from jump server, run below commands
kubectl get namespace
thor@jump_host /$ kubectl get namespace
NAME STATUS AGE
default Active 6m51s
kube-node-lease Active 6m56s
kube-public Active 6m56s
kube-system Active 6m57s
thor@jump_host /$
kubectl get services
thor@jump_host /$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 443/TCP 7m43s
thor@jump_host /$
2.Create namespace as per the task request.
kubectl create namespace tomcat-namespace-devops
thor@jump_host /$ kubectl get namespace
NAME STATUS AGE
default Active 8m41s
kube-node-lease Active 8m46s
kube-public Active 8m46s
kube-system Active 8m47s
tomcat-namespace-devops Active 24s
thor@jump_host /$
3.Create deploy.yaml file using --dry-run command and modify later.
kubectl create deploy tomcat-namespace-devops --image=Google Cloud console --dry-run=client -o yaml > deploy.yaml
thor@jump_host ~$ kubectl create deploy tomcat-namespace-devops --image=Google Cloud console --dry-run=client -o yaml > deploy.yaml
thor@jump_host ~$ cat deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: tomcat-namespace-devops
name: tomcat-namespace-devops
spec:
replicas: 1
selector:
matchLabels:
app: tomcat-namespace-devops
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: tomcat-namespace-devops
spec:
containers:
- image: Google Cloud console
name: centos-ssh-enabled
resources: {}
status: {}
thor@jump_host ~$ vi deploy.yaml
thor@jump_host ~$ cat deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment-devops
spec:
replicas: 1
selector:
matchLabels:
app: tomcat-deployment-devops
template:
metadata:
labels:
app: tomcat-deployment-devops
spec:
containers:
- image: Google Cloud console
name: tomcat-container-devops
ports:
- containerPort: 8080
thor@jump_host ~$
thor@jump_host ~$ kubectl apply -f deploy.yaml
deployment.apps/tomcat-deployment-devops created
thor@jump_host ~$ kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
tomcat-deployment-devops 0/1 1 0 31s
thor@jump_host ~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
tomcat-deployment-devops-69dc548484-zgfvs 0/1 ContainerCreating 0 39s
thor@jump_host ~$
4.Create service.yaml file using --dry-run command and modify later.
kubectl expose deploy tomcat-deployment-devops --name=tomcat-service-devops --type=NodePort --port=80 --target-port=8080 --dry-run=client -o yaml > service.yaml
thor@jump_host ~$ kubectl expose deploy tomcat-deployment-devops --name=tomcat-service-devops --type=NodePort --port=80 --target-port=8080 --dry-run=client -o yaml > service.yaml
thor@jump_host ~$ cat service.yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
name: tomcat-service-devops
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8080
selector:
app: tomcat-deployment-devops
type: NodePort
status:
loadBalancer: {}
thor@jump_host ~$ vi service.yaml
thor@jump_host ~$ cat service.yaml
apiVersion: v1
kind: Service
metadata:
name: tomcat-service-devops
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8080
nodePort: 32227
selector:
app: tomcat-deployment-devops
type: NodePort
thor@jump_host ~$
thor@jump_host ~$ kubectl apply -f service.yaml
service/tomcat-service-devops created
thor@jump_host ~$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 443/TCP 26m
tomcat-service-devops NodePort 10.110.151.65 80:32227/TCP 16s
thor@jump_host ~$
thor@jump_host ~$ kubectl get po,svc,ep -o wide --show-labels
I0305 14:48:45.159448 162 request.go:645] Throttling request took 1.131621248s, request: GET:https://172.17.0.9:6443/apis/extensions/v1beta1?timeout=32s
I0305 14:48:55.162134 162 request.go:645] Throttling request took 6.396120212s, request: GET:https://172.17.0.9:6443/apis/scheduling.k8s.io/v1?timeout=32s
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES LABELS
pod/tomcat-deployment-devops-69dc548484-zgfvs 1/1 Running 0 6m41s 10.244.1.2 node01 app=tomcat-deployment-devops,pod-template-hash=69dc548484
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR LABELS
service/kubernetes ClusterIP 10.96.0.1 443/TCP 26m component=apiserver,provider=kubernetes
service/tomcat-service-devops NodePort 10.110.151.65 80:32227/TCP 42s app=tomcat-deployment-devops
NAME ENDPOINTS AGE LABELS
endpoints/kubernetes 172.17.0.9:6443 26m endpointslice.kubernetes.io/skip-mirror=true
endpoints/tomcat-service-devops 10.244.1.2:8080 42s
thor@jump_host ~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
tomcat-deployment-devops-69dc548484-zgfvs 1/1 Running 0 7m51s
thor@jump_host ~$ kubectl get no -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
controlplane Ready master 30m v1.19.0 172.17.0.9 Ubuntu 18.04.5 LTS 4.15.0-122-generic docker://19.3.13
node01 Ready 29m v1.19.0 172.17.0.18 Ubuntu 18.04.5 LTS 4.15.0-122-generic docker://19.3.13
thor@jump_host ~$ curl 172.17.0.18:32227
SampleWebAppWelcome to xFusionCorp Industries!
</body>
thor@jump_host ~$