Skip to main content

Advanced Attribute Settings

This article introduces how to set advanced Kubernetes attributes for components, such as: privileged, affinity, etc.

Set Kubernetes Advanced Attributes​

In the component's other settings, you can set advanced Kubernetes attributes.When adding all attributes, there is no need to define the attribute name at the beginning, just add the attribute directly.

  • nodeSelector Schedule to the specified node

  • labels Labels

  • volumes Storage volumes, example as follows

    • name: config-vol configMap: name: log-config items:
      • key: log_level path: log_level
  • volumeMounts Volume mounts, example as follows

    • mountPath: /data name: redis-data
  • affinity Affinity, example as follows

    nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms:

    • matchExpressions:
      • key: kubernetes.io/hostname operator: NotIn values:
        • node3
  • tolerations Tolerations, example as follows:

    • key: "key1" operator: "Equal" value: "value1" effect: "NoSchedule" tolerationSeconds
  • Set serviceAccountName Service Account

  • privileged Privileged mode

  • env Environment variables, example as follows:

    • name: Version value: v5.8
    • name: NGINX_USERNAEM valueFrom: secretKeyRef: name: nginx-secret key: username optional: false
    • name: NGINX_PASSWORD valueFrom: secretKeyRef: name: nginx-secret key: password optional: false
    • name: MY_POD_IP valueFrom: fieldRef: fieldPath: status.podIP
  • shareProcessNamespace Share Process Namespace

  • dnsPolicy DNS Policy, example as follows:

    nameservers:

    • 1.2.3.4 searches:
    • ns1.svc.cluster-domain.example
    • my.dns.search.suffix options:
    • name: ndots value: "2"
    • name: edns0
  • resources Resource limits, example as follows:

    requests: memory: "1024Mi" cpu: "500m" limits: memory: "512Mi" cpu: "100m"

  • hostIPC Controls whether the container can share the host's IPC namespace

  • lifecycle Container lifecycle event setting handler, example as follows:

    postStart: exec: command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"] preStop: exec: command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]

  • hostAliases allows adding custom hostnames and corresponding IP addresses in the container's /etc/hosts file.Example as follows:

    • ip: "192.168.1.1" hostnames:
    • "alias1.example.com"
    • "alias2.example.com"
    • ip: "192.168.1.2" hostnames:
    • "alias3.example.com"