Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CKD new question #233

Open
gairik opened this issue Nov 5, 2021 · 8 comments
Open

CKD new question #233

gairik opened this issue Nov 5, 2021 · 8 comments

Comments

@gairik
Copy link

gairik commented Nov 5, 2021

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

@gairik
Copy link
Author

gairik commented Nov 6, 2021

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>

@szinck1
Copy link

szinck1 commented Nov 11, 2021

I don't see the label app=nginx on the second deployment.

@gairik
Copy link
Author

gairik commented Nov 12, 2021

I don't see the label app=nginx on the second deployment.

I can see it

@gairik gairik changed the title CDK new question CKD new question Nov 12, 2021
@santhu-msciflex
Copy link

santhu-msciflex commented Nov 22, 2021

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

@gairik
Copy link
Author

gairik commented Nov 22, 2021

@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.

@santhu-msciflex
Copy link

@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

@kaizendae
Copy link

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.

@MarcoPalomo
Copy link

This is made by a weighted load balancing solution (like istio or nginx for instance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants