Skip to content

helm: ability to set hostAliases on browser node deployments #1593

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 4 commits into from
Jun 22, 2022
Merged

helm: ability to set hostAliases on browser node deployments #1593

merged 4 commits into from
Jun 22, 2022

Conversation

anthonybaldwin
Copy link
Contributor

Description

  • Add the ability to set hostAliases on browser node deployments

Motivation and Context

  • App requires host entries to avoid hitting Cloudflare, so I am manually making these changes to alter every chart release
  • With this change, should be able to pass in using --set (if you can figure out the syntax...) or custom-values.yaml instead
    • Or to not change at all...

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@CLAassistant
Copy link

CLAassistant commented Jun 6, 2022

CLA assistant check
All committers have signed the CLA.

@diemol diemol requested a review from ilpianista June 7, 2022 09:15
@anthonybaldwin
Copy link
Contributor Author

The below may help check the change using my branch.

(Note: The force push is because I concluded 123. is bad; used documentation IPs instead. Open to replacing with hosts ending in .example if preferred, but I'm impartial.)

Save values-user.yaml to docker-selenium root:

chromeNode:
  hostAliases:
    - ip: "198.51.100.0"
      hostnames:
        - "example.com"
        - "example.net"
    - ip: "203.0.113.0"
      hostnames:
        - "example.org"
edgeNode:
  hostAliases:
    - ip: "198.51.100.0"
      hostnames:
        - "example.com"
        - "example.net"
    - ip: "203.0.113.0"
      hostnames:
        - "example.org"
firefoxNode:
  hostAliases:
    - ip: "198.51.100.0"
      hostnames:
        - "example.com"
        - "example.net"
    - ip: "203.0.113.0"
      hostnames:
        - "example.org"

Run this:

helm install selenium-grid \
  --values values-user.yaml \
  charts/selenium-grid/. \
  --dry-run --debug

The output browser deployment yamls (trimmed the rest to save space):

# Source: selenium-grid/templates/chrome-node-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: selenium-chrome-node
  namespace: localdev
  labels: &chrome_node_labels
    app: selenium-chrome-node
    app.kubernetes.io/name: selenium-chrome-node
    app.kubernetes.io/managed-by: helm
    app.kubernetes.io/instance: selenium-grid
    app.kubernetes.io/version: 4.2.1-20220531
    app.kubernetes.io/component: selenium-grid-4.2.1-20220531
    helm.sh/chart: selenium-grid-0.3.1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: selenium-chrome-node
  template:
    metadata:
      labels: *chrome_node_labels
      annotations:
        checksum/event-bus-configmap: dd260b62645a68911eccf59059c303dc74093e3722f57bc0bb69a49d63f11ecb
    spec:
      hostAliases: 
        - hostnames:
          - example.com
          - example.net
          ip: 198.51.100.0
        - hostnames:
          - example.org
          ip: 203.0.113.0
      containers:
        - name: selenium-chrome-node
          image: selenium/node-chrome:4.2.1-20220531
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: selenium-event-bus-config
          ports:
            - containerPort: 5553
              protocol: TCP
          volumeMounts:
            - name: dshm
              mountPath: /dev/shm
          resources:
            limits:
              cpu: "1"
              memory: 1Gi
            requests:
              cpu: "1"
              memory: 1Gi
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
            sizeLimit: 1Gi
---
# Source: selenium-grid/templates/edge-node-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: selenium-edge-node
  namespace: localdev
  labels: &edge_node_labels
    app: selenium-edge-node
    app.kubernetes.io/name: selenium-edge-node
    app.kubernetes.io/managed-by: helm
    app.kubernetes.io/instance: selenium-grid
    app.kubernetes.io/version: 4.2.1-20220531
    app.kubernetes.io/component: selenium-grid-4.2.1-20220531
    helm.sh/chart: selenium-grid-0.3.1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: selenium-edge-node
  template:
    metadata:
      labels: *edge_node_labels
      annotations:
        checksum/event-bus-configmap: dd260b62645a68911eccf59059c303dc74093e3722f57bc0bb69a49d63f11ecb
    spec:
      hostAliases: 
        - hostnames:
          - example.com
          - example.net
          ip: 198.51.100.0
        - hostnames:
          - example.org
          ip: 203.0.113.0
      containers:
        - name: selenium-edge-node
          image: selenium/node-edge:4.2.1-20220531
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: selenium-event-bus-config
          ports:
            - containerPort: 5553
              protocol: TCP
          volumeMounts:
            - name: dshm
              mountPath: /dev/shm
          resources:
            limits:
              cpu: "1"
              memory: 1Gi
            requests:
              cpu: "1"
              memory: 1Gi
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
            sizeLimit: 1Gi
---
# Source: selenium-grid/templates/firefox-node-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: selenium-firefox-node
  namespace: localdev
  labels: &firefox_node_labels
    app: selenium-firefox-node
    app.kubernetes.io/name: selenium-firefox-node
    app.kubernetes.io/managed-by: helm
    app.kubernetes.io/instance: selenium-grid
    app.kubernetes.io/version: 4.2.1-20220531
    app.kubernetes.io/component: selenium-grid-4.2.1-20220531
    helm.sh/chart: selenium-grid-0.3.1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: selenium-firefox-node
  template:
    metadata:
      labels: *firefox_node_labels
      annotations:
        checksum/event-bus-configmap: dd260b62645a68911eccf59059c303dc74093e3722f57bc0bb69a49d63f11ecb
    spec:
      hostAliases: 
        - hostnames:
          - example.com
          - example.net
          ip: 198.51.100.0
        - hostnames:
          - example.org
          ip: 203.0.113.0
      containers:
        - name: selenium-firefox-node
          image: selenium/node-firefox:4.2.1-20220531
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: selenium-event-bus-config
          ports:
            - containerPort: 5553
              protocol: TCP
          volumeMounts:
            - name: dshm
              mountPath: /dev/shm
          resources:
            limits:
              cpu: "1"
              memory: 1Gi
            requests:
              cpu: "1"
              memory: 1Gi
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
            sizeLimit: 1Gi
...

Matches example here (minus IP/hostnames being re-ordered, but works either way): https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/#adding-additional-entries-with-hostaliases

To confirm on pods (disclude --dry-run --debug on helm install):

trunk kubectl exec selenium-chrome-node-f5d78774b-lgkcx -- cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
fe00::0	ip6-mcastprefix
fe00::1	ip6-allnodes
fe00::2	ip6-allrouters
10.88.1.23	selenium-chrome-node-f5d78774b-lgkcx

# Entries added by HostAliases.
198.51.100.0	example.com	example.net
203.0.113.0	example.org

trunk kubectl exec selenium-edge-node-7b5d87cd5d-x96l5 -- cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
fe00::0	ip6-mcastprefix
fe00::1	ip6-allnodes
fe00::2	ip6-allrouters
10.88.1.22	selenium-edge-node-7b5d87cd5d-x96l5

# Entries added by HostAliases.
198.51.100.0	example.com	example.net
203.0.113.0	example.org

trunk kubectl exec selenium-firefox-node-66fb654d78-kszxp -- cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
fe00::0	ip6-mcastprefix
fe00::1	ip6-allnodes
fe00::2	ip6-allrouters
10.88.0.23	selenium-firefox-node-66fb654d78-kszxp

# Entries added by HostAliases.
198.51.100.0	example.com	example.net
203.0.113.0	example.org

@anthonybaldwin
Copy link
Contributor Author

Friendly bump on this @ilpianista @diemol

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

Could you please also update Chart.yaml and the CHANGELOG so we can release right away?

@anthonybaldwin
Copy link
Contributor Author

Done 👍

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

Thank you, @anthonybaldwin!

@diemol diemol merged commit 43972f6 into SeleniumHQ:trunk Jun 22, 2022
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