Skip to content

feat: add tolerations, affinity, volumes & volumeMounts #9

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

Merged
merged 10 commits into from
Apr 18, 2023

Conversation

ishanarya0
Copy link
Member

@ishanarya0 ishanarya0 commented Apr 13, 2023

This shall allow adding tolerations to firehose and affinity pods.

In firehose values.yaml, you can add the following at the root level

tolerations:
  - key: "k1"
    operator: "Equal"
    value: "v1"
    effect: "NoSchedule"

nodeAffinitiyMatchExpressions:
  requiredDuringSchedulingIgnoredDuringExecution:
  - key: "k1"
    operator: "Equal"
    values:
      - "v11"
      - "v12"
  - key: "k2"
    operator: "Equal"
    values:
      - "v21"
      - "v22"
  preferredDuringSchedulingIgnoredDuringExecution:
  - weight: "1"
    preference:
      - key: "k1"
        operator: "Equal"
        values:
          - "v001"
          - "v002"
      - key: "k2"
        operator: "Equal"
        values:
          - "v003"
          - "v004"
  - weight: "2"
    preference:
      - key: "k3"
        operator: "Equal"
        values:
          - "v005"
          - "v005"

And it shall generate

# Source: firehose/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment.yaml-firehose
  namespace: default
  labels:
    application: firehose
spec:
  replicas: 1
  selector:
    matchLabels:
      app: deployment.yaml-firehose
  template:
    metadata:
      annotations:
        checksum/config: cfa35c246f70b4c1cf0ac0a2b44229ef407f42173d7f8c9c3efd4951267a6315
      labels:
        app: deployment.yaml-firehose
        application: firehose
    spec:
      containers:
      - args:
        - java
        - -cp
        - bin/*:/work-dir/*
        - com.gotocompany.firehose.launch.Main
        - -server
        - -Dlogback.configurationFile=etc/firehose/logback.xml
        - -Xloggc:/var/log/firehose
        name: firehose
        image: "gotocompany/firehose:1.1.0"
        imagePullPolicy: IfNotPresent
        volumeMounts:
        resources:
            limits:
              cpu: 200m
              memory: 512Mi
            requests:
              cpu: 200m
              memory: 512Mi
        envFrom:
          - configMapRef:
              name: deployment.yaml-firehose-config
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
      volumes:
      tolerations:
        - key: k1
          operator: Equal
          value: v1
          effect: NoSchedule
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: k1
                    operator: Equal
                    values:
                      - v11
                      - v12
                  - key: k2
                    operator: Equal
                    values:
                      - v21
                      - v22
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1   
              preference:   
                matchExpressions:   
                  - key: k1
                    operator: Equal
                    values:
                      - v001
                      - v002   
                  - key: k2
                    operator: Equal
                    values:
                      - v003
                      - v004
            - weight: 2   
              preference:   
                matchExpressions:   
                  - key: k3
                    operator: Equal
                    values:
                      - v005
                      - v005

Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity

@ishanarya0 ishanarya0 requested a review from spy16 April 13, 2023 07:49
@ishanarya0 ishanarya0 changed the title feat: add taint/tolerations feat: add tolerations & affinity Apr 13, 2023
@ishanarya0 ishanarya0 changed the title feat: add tolerations & affinity feat: add tolerations, affinity, volumes & volumeMounts Apr 14, 2023
@ishanarya0 ishanarya0 requested a review from spy16 April 14, 2023 11:04
Copy link

@StewartJingga StewartJingga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can you help updating chart version and readme

@ishanarya0 ishanarya0 merged commit f71ebbd into main Apr 18, 2023
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

Successfully merging this pull request may close these issues.

3 participants