Main Menu

Search

KUBERNETES: Deploy Sample nginx Weblogic (from Docker.io) to Kubernetes Cluster For Testing

KUBERNETES: Deploy Sample nginx Weblogic (from Docker.io) to Kubernetes Cluster For Testing

1) Create nginx deployment yaml file. For e.g. nginx.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: my-webapp
spec:
replicas: 3
selector:
matchLabels:
app: my-webapp
template:
metadata:
labels:
app: my-webapp
spec:
containers:
- name: my-webapp
image: nginx:1.7.9
ports:
- containerPort: 80

2)Create nginx service yaml file to listen on the Nodeport. For e.g. nginx-service-nodeport.yaml
apiVersion: v1
kind: Service
metadata:
  name: my-webapp-service
spec:
  selector:
    app: my-webapp
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30007
  type: NodePort
3) Deployment the nginx webapp and create service. 
kubectl apply -f nginx.yaml
kubectl apply -f nginx-service-nodeport.yaml
4) Check the deployment and service are created in default namespace.
For this run below command.
kubectl get all
Below is sample output.
NAME                             READY   STATUS    RESTARTS   AGE
pod/my-webapp-6c854bcc4c-256kh   1/1     Running   0          8m19s
pod/my-webapp-6c854bcc4c-ghnnv   1/1     Running   0          8m19s
pod/my-webapp-6c854bcc4c-v87jj   1/1     Running   0          8m19s

NAME                        TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
service/kubernetes          ClusterIP   10.96.0.1       <none>        443/TCP        3d20h
service/my-webapp-service   NodePort    10.101.27.114   <none>        80:30007/TCP   6m50s

NAME                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/my-webapp   3/3     3            3           8m19s

NAME                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/my-webapp-6c854bcc4c   3         3         3       8m19s
5) Acccess the nginx webapp using nodeport 30007 and Kubernetes machine IP where pod is running.
http://IP:30007


keywords
deploying install installing nginx example sample samples examples web app webapp application services


No comments:

Post a Comment