Deploy a microservice in Kubernetes
First we have to create the Deployment file and save it as demo-deployment.yaml
This YAML document describes a Deployment named
hello
with 3 replicas of a Pod namedhello-app
running a container with the remote imagegcr.io/google-samples/hello-app:1.0
.For more information visit: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
labels:
role: hello
spec:
replicas: 3
selector:
matchLabels:
role: hello
tier: web
template:
metadata:
labels:
role: hello
tier: web
spec:
containers:
- name: hello-app
image: gcr.io/google-samples/hello-app:1.0
ports:
- containerPort: 8080
Next, to actually create the deployment we execute the following:
kubectl apply -f demo-deployment.yaml
To verify the status and information of the deployment use:
kubectl get deployments
To check the pods created by the service use:
kubectl get pods
You should see 3
hello-app
pods (one for each replica)
Reference Links
Last updated