diff --git a/helm/vitess/templates/NOTES.txt b/helm/vitess/templates/NOTES.txt index e69de29bb2d..a08bd9830f4 100644 --- a/helm/vitess/templates/NOTES.txt +++ b/helm/vitess/templates/NOTES.txt @@ -0,0 +1,15 @@ +{{- $cell := (index .Values.topology.cells 1).name -}} +{{- $proxyURL := printf "http://localhost:8001/api/v1/proxy/namespaces/%s" .Release.Namespace -}} + +Release name: {{.Release.Name}} + +To access administrative web pages, start a proxy with: + kubectl proxy --port=8001 + +Then use the following URLs: + +Kubernetes dashboard: http://localhost:8001/ui + +vtctld: {{$proxyURL}}/services/vtctld:web/ +vtgate: {{$proxyURL}}/services/vtgate-{{$cell}}:web/ + diff --git a/helm/vitess/templates/_helpers.tpl b/helm/vitess/templates/_helpers.tpl index 2da48fe008c..b32a04e6201 100644 --- a/helm/vitess/templates/_helpers.tpl +++ b/helm/vitess/templates/_helpers.tpl @@ -14,3 +14,23 @@ {{- range . }}{{template "format-flags" .}}{{end -}} {{- end -}} +# Common init-container to set up vtdataroot volume. +{{- define "init-vtdataroot" -}} +{{- $image := . -}} +{ + "name": "init-vtdataroot", + "image": {{$image | quote}}, + "command": ["bash", "-c", " + set -ex; + mkdir -p $VTDATAROOT/tmp; + chown vitess:vitess $VTDATAROOT $VTDATAROOT/tmp; + "], + "volumeMounts": [ + { + "name": "vtdataroot", + "mountPath": "/vt/vtdataroot" + } + ] +} +{{- end -}} + diff --git a/helm/vitess/templates/_vtctld.tpl b/helm/vitess/templates/_vtctld.tpl index f35ce547107..32f305c1f24 100644 --- a/helm/vitess/templates/_vtctld.tpl +++ b/helm/vitess/templates/_vtctld.tpl @@ -33,6 +33,10 @@ spec: labels: component: vtctld app: vitess + annotations: + pod.beta.kubernetes.io/init-containers: '[ +{{ include "init-vtdataroot" (.image | default $0.image) | indent 10 }} + ]' spec: containers: - name: vtctld @@ -55,31 +59,29 @@ spec: mountPath: /etc/ssl/certs/ca-certificates.crt resources: {{ toYaml (.resources | default $0.resources) | indent 12 }} + securityContext: + runAsUser: 999 command: - bash - "-c" - | set -ex - mkdir -p $VTDATAROOT/tmp - chown -R vitess /vt - - exec su -p -c "$(tr '\n' ' ' < $VTDATAROOT/init/tablet-uid\n + "], + "volumeMounts": [ + { + "name": "vtdataroot", + "mountPath": "/vt/vtdataroot" + } + ] +} +{{- end -}} + +# vttablet StatefulSet +{{- define "vttablet-stateful-set" -}} +{{- $ := index . 0 -}} +{{- $cell := index . 1 -}} +{{- $keyspace := index . 2 -}} +{{- $shard := index . 3 -}} +{{- $tablet := index . 4 -}} +{{- with $tablet.vttablet -}} +{{- $0 := $.Values.vttablet -}} +{{- $keyspaceClean := $keyspace.name | replace "_" "-" -}} +{{- $setName := printf "%s-%s-%s" $keyspaceClean $shard.name $tablet.type | lower -}} +{{- $uid := "$(cat $VTDATAROOT/init/tablet-uid)" }} +# vttablet StatefulSet +apiVersion: apps/v1alpha1 +kind: PetSet +metadata: + name: {{$setName | quote}} +spec: + serviceName: vttablet + replicas: {{.replicas | default $0.replicas}} + template: + metadata: + labels: + app: vitess + component: vttablet + keyspace: {{$keyspace.name | quote}} + shard: {{$shard.name | quote}} + type: {{$tablet.type | quote}} + annotations: + pod.alpha.kubernetes.io/initialized: "true" + pod.beta.kubernetes.io/init-containers: '[ +{{ include "init-vtdataroot" (.image | default $0.image) | indent 10 }}, +{{ include "init-tablet-uid" (tuple (.image | default $0.image) $cell) | indent 10 }} + ]' + spec: +{{ include "vttablet-pod-spec" (tuple $ $cell $keyspace $shard $tablet $uid .) | indent 6 }} +{{ if eq (.dataVolumeType | default $0.dataVolumeType) "PersistentVolume" }} + volumeClaimTemplates: + - metadata: + name: vtdataroot + annotations: +{{ toYaml (.dataVolumeClaimAnnotations | default $0.dataVolumeClaimAnnotations) | indent 10 }} + spec: +{{ toYaml (.dataVolumeClaimSpec | default $0.dataVolumeClaimSpec) | indent 8 }} +{{ end }} +{{- end -}} +{{- end -}} + +# vttablet naked pod (not using StatefulSet) +{{- define "vttablet-pod" -}} +{{- $ := index . 0 -}} +{{- $cell := index . 1 -}} +{{- $keyspace := index . 2 -}} +{{- $shard := index . 3 -}} +{{- $tablet := index . 4 -}} +{{- $uid := index . 5 -}} +{{- with $tablet.vttablet -}} +{{- $0 := $.Values.vttablet -}} # vttablet kind: Pod apiVersion: v1 metadata: name: "vttablet-{{$uid}}" labels: + app: vitess component: vttablet keyspace: {{$keyspace.name | quote}} shard: {{$shard.name | quote}} - tablet: {{$alias | quote}} - app: vitess + type: {{$tablet.type | quote}} + annotations: + pod.beta.kubernetes.io/init-containers: '[ +{{ include "init-vtdataroot" (.image | default $0.image) | indent 6 }} + ]' spec: - containers: - - name: vttablet - image: {{.image | default $0.image | quote}} - livenessProbe: - httpGet: - path: /debug/vars - port: 15002 - initialDelaySeconds: 60 - timeoutSeconds: 10 - volumeMounts: - - name: syslog - mountPath: /dev/log - - name: vtdataroot - mountPath: /vt/vtdataroot - - name: certs - readOnly: true - # Mount root certs from the host OS into the location - # expected for our container OS (Debian): - mountPath: /etc/ssl/certs/ca-certificates.crt - resources: -{{ toYaml (.resources | default $0.resources) | indent 8 }} - ports: - - name: web - containerPort: 15002 - - name: grpc - containerPort: 16002 - command: - - bash - - "-c" - - | - set -ex - mkdir -p $VTDATAROOT/tmp - chown -R vitess /vt - - exec su -p -c "$(tr '\n' ' ' <