Main Menu

Search

Showing posts with label kubernetes app deployment. Show all posts
Showing posts with label kubernetes app deployment. Show all posts

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


KUBERNETES How to Start / Run Temporary Pod On Specific Node In Kubernetes

You can start a pod temporarily on specific node for testing by using kubectl command as follows:

kubectl run <name> --image=<image> --overrides='{"apiVersion": "v1", "spec": {"nodeSelector": {"kubernetes.io/hostname": "<hostname>"}}}' --restart=Never

With above command a temporary pod with specified name and image will be started on the node specified. The pod will not start once you delete the pod since restart is specified as "Never".

For e.g. to start nginx pod using nginx image in Oracle container registry on worker1 node, your command will look as follows:

kubectl run nginx --image=container-registry.oracle.com/olcne/nginx:1.17.7 --overrides='{"apiVersion": "v1", "spec": {"nodeSelector": {"kubernetes.io/hostname": "worker1"}}}' --restart=Never


Keywords:

temporarily starting running pod pods test testing without deployment deployments yaml file files pull pulliing particular desired choice

KUBERNETES: How to Start / Run Temporary Pod For Testing In Kubernetes

You can start a pod temporarily for testing by using kubectl command as follows:

kubectl run <name> --image=<image> --restart=Never

With above command a temporay pod with specified name and image will be deployed. The pod will not start once you delete the pod since restart is specified as "Never"

For e.g. to start nginx pod using nginx image in Oracle container registry, your command will look as follows:

kubectl run nginx --image=container-registry.oracle.com/olcne/nginx:1.17.7 --restart=Never


Keywords:

temporarily starting running pod pods test testing without deployment deployments yaml file files pull pulliing