#
Deploy an NGINX server in a Kubernetes Cluster in Azure
This tutorial explains how we can deploy an NGINX server in a Kubernetes Cluster in Azure.
First of all, we need to prepare the deployment YAML file. This file is named my-first-deployment.yml.
Here we have the content of my-first-deployment.yml :
powerpoint my-first-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-first-deploy
spec:
replicas: 4
selector:
matchLabels:
app: app1
minReadySeconds: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: app1
spec:
containers:
- name: app1-pod
image: nginx:1.16.1
ports:
- containerPort: 8080
The following command will create a new Deployment:
powerpoint
kubectl apply -f my-first-deployment.yml
Info
kubectl
command POSTs the manifest to the API server.- Because we define what we want to have first, this is considered a
Declarative
way of creating Deployments.
We can run the following command to see the result:
kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
my-first-deploy 4/4 4 4 2m38s
Get more information on a specific Deployment:
kubectl describe deployment my-first-deploy
In my case the result is:
Name: my-first-deploy
Namespace: default
CreationTimestamp: Sat, 04 Feb 2023 16:22:47 +0200
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=app1
Replicas: 4 desired | 4 updated | 4 total | 4 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 10
RollingUpdateStrategy: 1 max unavailable, 1 max surge
Pod Template:
Labels: app=app1
Containers:
app1-pod:
Image: nginx:1.16.1
Port: 8080/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: my-first-deploy-74dd4f4676 (4/4 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 3m24s deployment-controller Scaled up replica set my-first-deploy-74dd4f4676 to 4
We can delete the Deployment created above using the following command:
kubectl delete deployment my-first-deploy