Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Jay's Kubernetes learning notes

Jay's Kubernetes K8s Cheatsheet Notes

Taints and tolerations

taints.tpl:

{{printf "%-50s %-12s\n" "Node" "Taint"}}
{{- range .items}}
    {{- if $taint := (index .spec "taints") }}
        {{- .metadata.name }}{{ "\t" }}
        {{- range $taint }}
            {{- .key }}={{ .value }}:{{ .effect }}{{ "\t" }}
        {{- end }}
        {{- "\n" }}
    {{- end}}
{{- end}}
$ kubectl get nodes -o go-template-file=taints.tpl

Node                                               Taint
bus00evo	node-role.kubernetes.io/master=<no value>:NoSchedule

or

$ kubectl describe nodes bus00evo

Name:			bus00evo
...
Taints:			node-role.kubernetes.io/master:NoSchedule
...

Remove taint

Use the key name with a - suffix.

$ kubectl taint nodes bus00evo node-role.kubernetes.io/master-

node "bus00evo" untainted
$ kubectl get nodes -o go-template-file=taints.tpl

Node                                               Taint

Good.

See also:

Labels

Show labels

$ kubectl get nodes --show-labels

NAME       STATUS    AGE       VERSION          LABELS
bus00epb   Ready     17h       v1.8.1   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=bus00epb
bus00evo   Ready     17h       v1.8.1   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=bus00evo,node-role.kubernetes.io/master=

Add a label

$ kubectl label nodes bus00epb storage-zone=1

node "bus00epb" labeled

Verify:

$ kubectl get nodes --show-labels

NAME       STATUS    AGE       VERSION          LABELS
bus00epb   Ready     17h       v1.8.1   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=bus00epb,storage-zone=1
bus00evo   Ready     17h       v1.8.1   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=bus00evo,node-role.kubernetes.io/master=

Good.

Remove a label

Same command as adding a label, with the addition of a - suffix on the key (instead of a value).

$ kubectl label nodes bus00epb storage-zone-

node "bus00evo" labeled

Verify:

$ kubectl get nodes --show-labels

NAME       STATUS    AGE       VERSION          LABELS
bus00epb   Ready     17h       v1.8.1   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=bus00epb
bus00evo   Ready     17h       v1.8.1   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=bus00evo,node-role.kubernetes.io/master=

Good.

See also:

Preview Generated Helm YAML

With numbered lines:

$ helm install --debug --dry-run . 2>&1 | awk '{printf "%d\t%s\n", NR, $0}' | less

1       [debug] Created tunnel using local port: '39538'
2
3       [debug] SERVER: "localhost:39538"
4
5       [debug] Original chart version: ""
6       [debug] CHART PATH: ...
7
8       Error: YAML parse error on CHART-NAME: error converting YAML to JSON: yaml: line 35: did not find expected '-' indicator
9
10      ---
11      # Source: file.yaml
12      apiVersion: apps/v1beta1
13      kind: Deployment
...

Install Helm Chart

$ cd /path/to/chart/directory
$ helm install -f values.yaml .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment