Open gairik opened 3 years ago
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx-green
spec:
replicas: 3
selector:
matchLabels:
app: nginx
color: green
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx
color: green
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: /usr/share/nginx/html/index.html
name: nginx-conf
subPath: index.html
volumes:
- name: nginx-conf
configMap:
name: config-green
---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx-blue
name: nginx-blue
spec:
replicas: 1
selector:
matchLabels:
app: nginx
color: blue
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx
color: blue
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: /usr/share/nginx/html/index.html
name: nginx-conf
subPath: index.html
volumes:
- name: nginx-conf
configMap:
name: config
Service
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: nginx-blue
name: nginx-blue
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: NodePort
status:
loadBalancer: {}
Config maps
Name: config-green
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
index.html:
----
GREEEN
Events: <none>
Name: config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
index.html:
----
Blue deployment
Events: <none>
I don't see the label app=nginx
on the second deployment.
I don't see the label
app=nginx
on the second deployment.
I can see it
If I am not wrong, it was canary deployment scenario. You had one deployment already running and given another deployment to be executed. After executing the second deployment use kubectl scale deployment blue-deployment-name replicas=3 kubectl scale deployment green-deployment-name replicas=1
@santhu-msciflex Can you please point me to a documentation that says 3:1 pod ratio will automatically load balance? I tried to do the same however I did not get the same result. It was totally random.
@gairik - I couldn't get the 3:1 ratio when tested locally using docker-desktop. service type as LoadBalancer might be a solution. Referring to link https://phoenixnap.com/kb/kubernetes-canary-deployments
Having a ratio of 3:1 in the number of PODs does not imply that traffic will be split 3:1, but it does imply that a small portion of the traffic will go to canary, which is the goal of canary in the first place.
This is made by a weighted load balancing solution (like istio or nginx for instance).
Create a similar 2 deployment and mark them as Blue and Green. Create a Service so that the load is balanced between Blue and Green at 75%-25% ratio. Does anyone know how can we do this kind if question? I tried doing this by create deployments of 2 different pods of 3 numbers and 1 number and expected to the traffic to flow that way. However i am not successful. If you want to try, I have also created a sample for you to try. look below. If you know the answer please let me know below