Skip to content
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

k8s: Support StatefulSet and PersistentVolume in Helm chart #2248

Merged
merged 4 commits into from Nov 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions 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/

20 changes: 20 additions & 0 deletions helm/vitess/templates/_helpers.tpl
Expand Up @@ -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 -}}

40 changes: 21 additions & 19 deletions helm/vitess/templates/_vtctld.tpl
Expand Up @@ -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
Expand All @@ -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' ' ' <<END_OF_COMMAND
exec /vt/bin/vtctld
-cell {{$cell.name | quote}}
-web_dir "$VTTOP/web/vtctld"
-web_dir2 "$VTTOP/web/vtctld2/app"
-workflow_manager_init
-workflow_manager_use_election
-log_dir "$VTDATAROOT/tmp"
-alsologtostderr
-port 15000
-grpc_port 15999
-service_map "grpc-vtctl"
-topo_implementation "etcd"
-etcd_global_addrs "http://etcd-global:4001"
{{ include "format-flags-all" (tuple $.Values.backupFlags $0.extraFlags .extraFlags) | indent 18 }}
eval exec /vt/bin/vtctld $(cat <<END_OF_COMMAND
-cell={{$cell.name | quote}}
-web_dir="$VTTOP/web/vtctld"
-web_dir2="$VTTOP/web/vtctld2/app"
-workflow_manager_init
-workflow_manager_use_election
-log_dir="$VTDATAROOT/tmp"
-alsologtostderr
-port=15000
-grpc_port=15999
-service_map="grpc-vtctl"
-topo_implementation="etcd"
-etcd_global_addrs="http://etcd-global:4001"
{{ include "format-flags-all" (tuple $.Values.backupFlags $0.extraFlags .extraFlags) | indent 16 }}
END_OF_COMMAND
)" vitess
)
volumes:
- name: syslog
hostPath: {path: /dev/log}
Expand Down
38 changes: 20 additions & 18 deletions helm/vitess/templates/_vtgate.tpl
Expand Up @@ -36,6 +36,10 @@ spec:
component: vtgate
cell: {{$cell.name}}
app: vitess
annotations:
pod.beta.kubernetes.io/init-containers: '[
{{ include "init-vtdataroot" (.image | default $0.image) | indent 10 }}
]'
spec:
containers:
- name: vtgate
Expand All @@ -53,30 +57,28 @@ spec:
mountPath: /vt/vtdataroot
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' ' ' <<END_OF_COMMAND
exec /vt/bin/vtgate
-topo_implementation "etcd"
-etcd_global_addrs "http://etcd-global:4001"
-log_dir "$VTDATAROOT/tmp"
-alsologtostderr
-port 15001
-grpc_port 15991
-service_map "grpc-vtgateservice"
-cells_to_watch {{$cell.name | quote}}
-tablet_types_to_wait "MASTER,REPLICA"
-gateway_implementation "discoverygateway"
-cell {{$cell.name | quote}}
{{ include "format-flags-all" (tuple $0.extraFlags .extraFlags) | indent 18 }}
eval exec /vt/bin/vtgate $(cat <<END_OF_COMMAND
-topo_implementation="etcd"
-etcd_global_addrs="http://etcd-global:4001"
-log_dir="$VTDATAROOT/tmp"
-alsologtostderr
-port=15001
-grpc_port=15991
-service_map="grpc-vtgateservice"
-cells_to_watch={{$cell.name | quote}}
-tablet_types_to_wait="MASTER,REPLICA"
-gateway_implementation="discoverygateway"
-cell={{$cell.name | quote}}
{{ include "format-flags-all" (tuple $0.extraFlags .extraFlags) | indent 16 }}
END_OF_COMMAND
)" vitess
)
volumes:
- name: syslog
hostPath: {path: /dev/log}
Expand Down