Skip to content

Commit

Permalink
k8s: Make vtctld a replication controller, and other fixes.
Browse files Browse the repository at this point in the history
vtctld should be a replication controller rather than a single pod,
so it gets restarted if the node fails.

Also made other fixes as suggested in a review by some Kubernetes folks.
  • Loading branch information
enisoc committed Sep 26, 2015
1 parent 5be1349 commit b8aa8fc
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 74 deletions.
13 changes: 6 additions & 7 deletions examples/kubernetes/etcd-controller-template.yaml
Expand Up @@ -2,19 +2,14 @@ apiVersion: v1
kind: ReplicationController
metadata:
name: etcd-{{cell}}
labels:
name: etcd
cell: {{cell}}
spec:
replicas: {{replicas}}
selector:
name: etcd
cell: {{cell}}
template:
metadata:
labels:
name: etcd
component: etcd
cell: {{cell}}
app: vitess
spec:
volumes:
- name: certs
Expand All @@ -34,6 +29,10 @@ spec:
# Mount root certs from the host OS into the location
# expected for our container OS (Debian):
mountPath: /etc/ssl/certs/ca-certificates.crt
resources:
limits:
memory: "128Mi"
cpu: "100m"
command:
- bash
- "-c"
Expand Down
7 changes: 4 additions & 3 deletions examples/kubernetes/etcd-service-template.yaml
Expand Up @@ -3,12 +3,13 @@ apiVersion: v1
metadata:
name: etcd-{{cell}}
labels:
name: etcd
component: etcd
cell: {{cell}}
app: vitess
spec:
ports:
- port: 4001
selector:
name: etcd
component: etcd
cell: {{cell}}

app: vitess
12 changes: 7 additions & 5 deletions examples/kubernetes/guestbook-controller.yaml
Expand Up @@ -2,19 +2,21 @@ kind: ReplicationController
apiVersion: v1
metadata:
name: guestbook
labels:
name: guestbook
spec:
replicas: 3
selector: {name: guestbook}
template:
metadata:
labels: {name: guestbook}
labels:
component: frontend
app: guestbook
spec:
containers:
- name: guestbook
image: vitess/guestbook
ports:
- name: http-server
containerPort: 8080

resources:
limits:
memory: "128Mi"
cpu: "100m"
7 changes: 6 additions & 1 deletion examples/kubernetes/guestbook-service.yaml
Expand Up @@ -2,10 +2,15 @@ kind: Service
apiVersion: v1
metadata:
name: guestbook
labels:
component: frontend
app: guestbook
spec:
ports:
- port: 80
targetPort: http-server
selector: {name: guestbook}
selector:
component: frontend
app: guestbook
type: LoadBalancer

45 changes: 45 additions & 0 deletions examples/kubernetes/vtctld-controller.yaml
@@ -0,0 +1,45 @@
kind: ReplicationController
apiVersion: v1
metadata:
name: vtctld
spec:
replicas: 1
template:
metadata:
labels:
component: vtctld
app: vitess
spec:
containers:
- name: vtctld
image: vitess/lite
volumeMounts:
- name: syslog
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
resources:
limits:
memory: "128Mi"
cpu: "100m"
command:
- sh
- "-c"
- >-
mkdir -p $VTDATAROOT/tmp &&
chown -R vitess /vt &&
su -p -c "/vt/bin/vtctld
-debug
-templates $VTTOP/go/cmd/vtctld/templates
-web_dir $VTTOP/web/vtctld
-log_dir $VTDATAROOT/tmp
-alsologtostderr
-port 15000
-topo_implementation etcd
-tablet_protocol grpc
-etcd_global_addrs http://$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT" vitess
volumes:
- name: syslog
hostPath: {path: /dev/log}
- name: vtdataroot
emptyDir: {}
4 changes: 2 additions & 2 deletions examples/kubernetes/vtctld-down.sh
Expand Up @@ -7,8 +7,8 @@ set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh

echo "Deleting vtctld pod..."
$KUBECTL delete pod vtctld
echo "Stopping vtctld replicationcontroller..."
$KUBECTL stop replicationcontroller vtctld

echo "Deleting vtctld service..."
$KUBECTL delete service vtctld
37 changes: 0 additions & 37 deletions examples/kubernetes/vtctld-pod.yaml

This file was deleted.

7 changes: 5 additions & 2 deletions examples/kubernetes/vtctld-service.yaml
Expand Up @@ -3,12 +3,15 @@ apiVersion: v1
metadata:
name: vtctld
labels:
name: vtctld
component: vtctld
app: vitess
spec:
ports:
- port: 15000
targetPort: 15000
nodePort: 30000
selector: {name: vtctld}
selector:
component: vtctld
app: vitess
type: NodePort

4 changes: 2 additions & 2 deletions examples/kubernetes/vtctld-up.sh
Expand Up @@ -10,8 +10,8 @@ source $script_root/env.sh
echo "Creating vtctld service..."
$KUBECTL create -f vtctld-service.yaml

echo "Creating vtctld pod..."
$KUBECTL create -f vtctld-pod.yaml
echo "Creating vtctld replicationcontroller..."
$KUBECTL create -f vtctld-controller.yaml

server=$(get_vtctld_addr)
echo
Expand Down
Expand Up @@ -2,13 +2,13 @@ kind: ReplicationController
apiVersion: v1
metadata:
name: vtgate
labels: {name: vtgate}
spec:
replicas: {{replicas}}
selector: {name: vtgate}
template:
metadata:
labels: {name: vtgate}
labels:
component: vtgate
app: vitess
spec:
containers:
- name: vtgate
Expand Down Expand Up @@ -44,4 +44,3 @@ spec:
hostPath: {path: /dev/log}
- name: vtdataroot
{{vtdataroot_volume}}

10 changes: 7 additions & 3 deletions examples/kubernetes/vtgate-controller-template.yaml
Expand Up @@ -2,13 +2,13 @@ kind: ReplicationController
apiVersion: v1
metadata:
name: vtgate
labels: {name: vtgate}
spec:
replicas: {{replicas}}
selector: {name: vtgate}
template:
metadata:
labels: {name: vtgate}
labels:
component: vtgate
app: vitess
spec:
containers:
- name: vtgate
Expand All @@ -18,6 +18,10 @@ spec:
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
resources:
limits:
memory: "512Mi"
cpu: "500m"
command:
- sh
- "-c"
Expand Down
9 changes: 6 additions & 3 deletions examples/kubernetes/vtgate-service.yaml
Expand Up @@ -2,10 +2,13 @@ kind: Service
apiVersion: v1
metadata:
name: vtgate
labels: {name: vtgate}
labels:
component: vtgate
app: vitess
spec:
ports:
- port: 15001
selector: {name: vtgate}
selector:
component: vtgate
app: vitess
type: LoadBalancer

2 changes: 1 addition & 1 deletion examples/kubernetes/vtgate-up.sh
Expand Up @@ -13,7 +13,7 @@ VTGATE_TEMPLATE=${VTGATE_TEMPLATE:-'vtgate-controller-template.yaml'}

vtdataroot_volume='emptyDir: {}'
if [ -n "$VTDATAROOT_VOLUME" ]; then
vtdataroot_volume="hostDir: {path: ${VTDATAROOT_VOLUME}}"
vtdataroot_volume="hostPath: {path: ${VTDATAROOT_VOLUME}}"
fi

replicas=$VTGATE_REPLICAS
Expand Down
3 changes: 2 additions & 1 deletion examples/kubernetes/vttablet-pod-benchmarking-template.yaml
Expand Up @@ -3,10 +3,11 @@ apiVersion: v1
metadata:
name: vttablet-{{uid}}
labels:
name: vttablet
component: vttablet
keyspace: "{{keyspace}}"
shard: "{{shard_label}}"
tablet: "{{alias}}"
app: vitess
spec:
containers:
- name: vttablet
Expand Down
11 changes: 10 additions & 1 deletion examples/kubernetes/vttablet-pod-template.yaml
Expand Up @@ -3,10 +3,11 @@ apiVersion: v1
metadata:
name: vttablet-{{uid}}
labels:
name: vttablet
component: vttablet
keyspace: "{{keyspace}}"
shard: "{{shard_label}}"
tablet: "{{alias}}"
app: vitess
spec:
containers:
- name: vttablet
Expand All @@ -16,6 +17,10 @@ spec:
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
resources:
limits:
memory: "1Gi"
cpu: "500m"
command:
- bash
- "-c"
Expand Down Expand Up @@ -72,6 +77,10 @@ spec:
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
resources:
limits:
memory: "1Gi"
cpu: "500m"
command:
- sh
- "-c"
Expand Down
2 changes: 1 addition & 1 deletion examples/kubernetes/vttablet-up.sh
Expand Up @@ -21,7 +21,7 @@ RDONLY_COUNT=${RDONLY_COUNT:-2}

vtdataroot_volume='emptyDir: {}'
if [ -n "$VTDATAROOT_VOLUME" ]; then
vtdataroot_volume="hostDir: {path: ${VTDATAROOT_VOLUME}}"
vtdataroot_volume="hostPath: {path: ${VTDATAROOT_VOLUME}}"
fi

uid_base=$UID_BASE
Expand Down
3 changes: 2 additions & 1 deletion examples/kubernetes/vtworker-pod-template.yaml
Expand Up @@ -3,7 +3,8 @@ apiVersion: v1
metadata:
name: vtworker
labels:
name: vtworker
component: vtworker
app: vitess
spec:
containers:
- name: vtworker
Expand Down

0 comments on commit b8aa8fc

Please sign in to comment.