21 | $ Hello World
22 | ```
23 |
24 |
25 |
26 | []()
27 |
28 |
--------------------------------------------------------------------------------
/examples/guestbook/legacy/frontend-controller.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ReplicationController
3 | metadata:
4 | name: frontend
5 | spec:
6 | replicas: 3
7 | template:
8 | metadata:
9 | labels:
10 | app: guestbook
11 | tier: frontend
12 | spec:
13 | containers:
14 | - name: php-redis
15 | image: gcr.io/google_samples/gb-frontend:v4
16 | resources:
17 | requests:
18 | cpu: 100m
19 | memory: 100Mi
20 | env:
21 | - name: GET_HOSTS_FROM
22 | value: dns
23 | # If your cluster config does not include a dns service, then to
24 | # instead access environment variables to find service host
25 | # info, comment out the 'value: dns' line above, and uncomment the
26 | # line below:
27 | # value: env
28 | ports:
29 | - containerPort: 80
30 |
--------------------------------------------------------------------------------
/examples/staging/volumes/glusterfs/glusterfs-pod.json:
--------------------------------------------------------------------------------
1 | {
2 | "apiVersion": "v1",
3 | "kind": "Pod",
4 | "metadata": {
5 | "name": "glusterfs"
6 | },
7 | "spec": {
8 | "containers": [
9 | {
10 | "name": "glusterfs",
11 | "image": "nginx",
12 | "volumeMounts": [
13 | {
14 | "mountPath": "/mnt/glusterfs",
15 | "name": "glusterfsvol"
16 | }
17 | ]
18 | }
19 | ],
20 | "volumes": [
21 | {
22 | "name": "glusterfsvol",
23 | "glusterfs": {
24 | "endpoints": "glusterfs-cluster",
25 | "path": "kube_vol",
26 | "readOnly": true
27 | }
28 | }
29 | ]
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/examples/staging/mysql-cinder-pd/mysql.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Pod
3 | metadata:
4 | name: mysql
5 | labels:
6 | name: mysql
7 | spec:
8 | containers:
9 | - resources:
10 | limits :
11 | cpu: 0.5
12 | image: mysql
13 | name: mysql
14 | args:
15 | - "--ignore-db-dir"
16 | - "lost+found"
17 | env:
18 | - name: MYSQL_ROOT_PASSWORD
19 | # change this
20 | value: yourpassword
21 | ports:
22 | - containerPort: 3306
23 | name: mysql
24 | volumeMounts:
25 | # name must match the volume name below
26 | - name: mysql-persistent-storage
27 | # mount path within the container
28 | mountPath: /var/lib/mysql
29 | volumes:
30 | - name: mysql-persistent-storage
31 | cinder:
32 | volumeID: bd82f7e2-wece-4c01-a505-4acf60b07f4a
33 | fsType: ext4
34 |
--------------------------------------------------------------------------------
/examples/cassandra/image/files/ready-probe.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2016 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | if [[ $(nodetool status | grep $POD_IP) == *"UN"* ]]; then
18 | if [[ $DEBUG ]]; then
19 | echo "UN";
20 | fi
21 | exit 0;
22 | else
23 | if [[ $DEBUG ]]; then
24 | echo "Not Up";
25 | fi
26 | exit 1;
27 | fi
28 |
--------------------------------------------------------------------------------
/examples/staging/newrelic/config-to-secret.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2014 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Encodes the environment variables into a Kubernetes secret.
18 |
19 | BASE64_ENC=$(cat nrconfig.env | base64 | tr -d '\n')
20 | sed -e "s#{{config_data}}#${BASE64_ENC}#g" ./newrelic-config-template.yaml > newrelic-config.yaml
21 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/vitess-down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | script_root=`dirname "${BASH_SOURCE}"`
18 | source $script_root/env.sh
19 |
20 | ./vtgate-down.sh
21 | SHARDS=$SHARDS CELLS=$CELLS TABLETS_PER_SHARD=$TABLETS_PER_SHARD ./vttablet-down.sh
22 | ./vtctld-down.sh
23 | ./etcd-down.sh
24 |
--------------------------------------------------------------------------------
/examples/staging/cluster-dns/images/backend/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | TAG = v1
16 | PREFIX = staging-k8s.gcr.io
17 | IMAGE = example-dns-backend
18 |
19 | all: push
20 |
21 | image:
22 | docker build --pull -t $(PREFIX)/$(IMAGE):$(TAG) .
23 |
24 | push: image
25 | gcloud docker -- push $(PREFIX)/$(IMAGE)
26 |
27 | clean:
28 |
--------------------------------------------------------------------------------
/examples/staging/cluster-dns/images/frontend/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | TAG = v1
16 | PREFIX = staging-k8s.gcr.io
17 | IMAGE = example-dns-frontend
18 |
19 | all: push
20 |
21 | image:
22 | docker build --pull -t $(PREFIX)/$(IMAGE):$(TAG) .
23 |
24 | push: image
25 | gcloud docker -- push $(PREFIX)/$(IMAGE)
26 |
27 | clean:
28 |
--------------------------------------------------------------------------------
/examples/staging/newrelic-infrastructure/config-to-secret.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2014 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Encodes the environment variables into a Kubernetes secret.
18 |
19 | BASE64_ENC=$(cat nrconfig.env | base64 | tr -d '\n')
20 | sed -e "s#{{config_data}}#${BASE64_ENC}#g" ./newrelic-config-template.yaml > newrelic-config.yaml
21 |
--------------------------------------------------------------------------------
/examples/staging/storage/redis/image/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM alpine:3.4
16 |
17 | RUN apk add --no-cache redis sed bash
18 |
19 | COPY redis-master.conf /redis-master/redis.conf
20 | COPY redis-slave.conf /redis-slave/redis.conf
21 | COPY run.sh /run.sh
22 |
23 | CMD [ "/run.sh" ]
24 |
25 | ENTRYPOINT [ "bash", "-c" ]
26 |
--------------------------------------------------------------------------------
/examples/staging/https-nginx/index2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Nginx reloaded!
5 |
12 |
13 |
14 | Nginx has been reloaded!
15 | If you see this page, the nginx web server has been automatically reloaded, since the config file has been updated using Kubernetes.
16 |
17 |
18 | For online documentation and support please refer to
19 | kubernetes.io.
20 |
21 | For online documentation and support please refer to
22 | nginx.org.
23 | Commercial support is available at
24 | nginx.com.
25 |
26 | Thank you for using nginx.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/guestbook-go/guestbook-controller.json:
--------------------------------------------------------------------------------
1 | {
2 | "kind":"ReplicationController",
3 | "apiVersion":"v1",
4 | "metadata":{
5 | "name":"guestbook",
6 | "labels":{
7 | "app":"guestbook"
8 | }
9 | },
10 | "spec":{
11 | "replicas":3,
12 | "selector":{
13 | "app":"guestbook"
14 | },
15 | "template":{
16 | "metadata":{
17 | "labels":{
18 | "app":"guestbook"
19 | }
20 | },
21 | "spec":{
22 | "containers":[
23 | {
24 | "name":"guestbook",
25 | "image":"k8s.gcr.io/guestbook:v3",
26 | "ports":[
27 | {
28 | "name":"http-server",
29 | "containerPort":3000
30 | }
31 | ]
32 | }
33 | ]
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/staging/phabricator/teardown.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | echo "Deleting Phabricator service" && kubectl delete -f phabricator-service.json
18 | echo "Deleting Phabricator replication controller" && kubectl delete rc phabricator-controller
19 | echo "Delete firewall rule" && gcloud compute firewall-rules delete -q phabricator-node-80
20 |
21 |
--------------------------------------------------------------------------------
/examples/staging/selenium/selenium-hub-deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: Deployment
3 | metadata:
4 | name: selenium-hub
5 | labels:
6 | app: selenium-hub
7 | spec:
8 | replicas: 1
9 | selector:
10 | matchLabels:
11 | app: selenium-hub
12 | template:
13 | metadata:
14 | labels:
15 | app: selenium-hub
16 | spec:
17 | containers:
18 | - name: selenium-hub
19 | image: selenium/hub:3.11
20 | ports:
21 | - containerPort: 4444
22 | resources:
23 | limits:
24 | memory: "1000Mi"
25 | cpu: ".5"
26 | livenessProbe:
27 | httpGet:
28 | path: /grid/console
29 | port: 4444
30 | initialDelaySeconds: 30
31 | timeoutSeconds: 5
32 | readinessProbe:
33 | httpGet:
34 | path: /grid/console
35 | port: 4444
36 | initialDelaySeconds: 30
37 | timeoutSeconds: 5
38 |
--------------------------------------------------------------------------------
/examples/staging/volumes/nfs/nfs-busybox-rc.yaml:
--------------------------------------------------------------------------------
1 | # This mounts the nfs volume claim into /mnt and continuously
2 | # overwrites /mnt/index.html with the time and hostname of the pod.
3 |
4 | apiVersion: v1
5 | kind: ReplicationController
6 | metadata:
7 | name: nfs-busybox
8 | spec:
9 | replicas: 2
10 | selector:
11 | name: nfs-busybox
12 | template:
13 | metadata:
14 | labels:
15 | name: nfs-busybox
16 | spec:
17 | containers:
18 | - image: busybox
19 | command:
20 | - sh
21 | - -c
22 | - 'while true; do date > /mnt/index.html; hostname >> /mnt/index.html; sleep $(($RANDOM % 5 + 5)); done'
23 | imagePullPolicy: IfNotPresent
24 | name: busybox
25 | volumeMounts:
26 | # name must match the volume name below
27 | - name: nfs
28 | mountPath: "/mnt"
29 | volumes:
30 | - name: nfs
31 | persistentVolumeClaim:
32 | claimName: nfs
33 |
--------------------------------------------------------------------------------
/examples/staging/https-nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM nginx
16 |
17 |
18 | COPY index2.html /usr/share/nginx/html/index2.html
19 | RUN chmod +r /usr/share/nginx/html/index2.html
20 | COPY auto-reload-nginx.sh /home/auto-reload-nginx.sh
21 | RUN chmod +x /home/auto-reload-nginx.sh
22 |
23 | # install inotify
24 | RUN apt-get update && apt-get install -y inotify-tools
25 |
--------------------------------------------------------------------------------
/examples/staging/spark/spark-gluster/spark-master-controller.yaml:
--------------------------------------------------------------------------------
1 | kind: ReplicationController
2 | apiVersion: v1
3 | metadata:
4 | name: spark-master-controller
5 | namespace: spark-cluster
6 | labels:
7 | component: spark-master
8 | spec:
9 | replicas: 1
10 | selector:
11 | component: spark-master
12 | template:
13 | metadata:
14 | labels:
15 | component: spark-master
16 | spec:
17 | containers:
18 | - name: spark-master
19 | image: k8s.gcr.io/spark:1.5.2_v1
20 | command: ["/start-master"]
21 | ports:
22 | - containerPort: 7077
23 | volumeMounts:
24 | - mountPath: /mnt/glusterfs
25 | name: glusterfsvol
26 | resources:
27 | requests:
28 | cpu: 100m
29 | volumes:
30 | - name: glusterfsvol
31 | glusterfs:
32 | endpoints: glusterfs-cluster
33 | path: MyVolume
34 | readOnly: false
35 |
--------------------------------------------------------------------------------
/examples/staging/phabricator/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | echo "Create Phabricator replication controller" && kubectl create -f phabricator-controller.json
18 | echo "Create Phabricator service" && kubectl create -f phabricator-service.json
19 | echo "Create firewall rule" && gcloud compute firewall-rules create phabricator-node-80 --allow=tcp:80 --target-tags kubernetes-node
20 |
21 |
--------------------------------------------------------------------------------
/examples/guestbook/legacy/redis-slave-controller.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ReplicationController
3 | metadata:
4 | name: redis-slave
5 | labels:
6 | app: redis
7 | role: slave
8 | tier: backend
9 | spec:
10 | replicas: 2
11 | template:
12 | metadata:
13 | labels:
14 | app: redis
15 | role: slave
16 | tier: backend
17 | spec:
18 | containers:
19 | - name: slave
20 | image: gcr.io/google_samples/gb-redisslave:v1
21 | resources:
22 | requests:
23 | cpu: 100m
24 | memory: 100Mi
25 | env:
26 | - name: GET_HOSTS_FROM
27 | value: dns
28 | # If your cluster config does not include a dns service, then to
29 | # instead access an environment variable to find the master
30 | # service's host, comment out the 'value: dns' line above, and
31 | # uncomment the line below:
32 | # value: env
33 | ports:
34 | - containerPort: 6379
35 |
--------------------------------------------------------------------------------
/examples/staging/spark/spark-gluster/spark-worker-controller.yaml:
--------------------------------------------------------------------------------
1 | kind: ReplicationController
2 | apiVersion: v1
3 | metadata:
4 | name: spark-gluster-worker-controller
5 | namespace: spark-cluster
6 | labels:
7 | component: spark-worker
8 | spec:
9 | replicas: 2
10 | selector:
11 | component: spark-worker
12 | template:
13 | metadata:
14 | labels:
15 | component: spark-worker
16 | uses: spark-master
17 | spec:
18 | containers:
19 | - name: spark-worker
20 | image: k8s.gcr.io/spark:1.5.2_v1
21 | command: ["/start-worker"]
22 | ports:
23 | - containerPort: 8888
24 | volumeMounts:
25 | - mountPath: /mnt/glusterfs
26 | name: glusterfsvol
27 | resources:
28 | requests:
29 | cpu: 100m
30 | volumes:
31 | - name: glusterfsvol
32 | glusterfs:
33 | endpoints: glusterfs-cluster
34 | path: MyVolume
35 | readOnly: false
36 |
--------------------------------------------------------------------------------
/examples/staging/storage/rethinkdb/rc.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ReplicationController
3 | metadata:
4 | labels:
5 | db: rethinkdb
6 | name: rethinkdb-rc
7 | spec:
8 | replicas: 1
9 | selector:
10 | db: rethinkdb
11 | role: replicas
12 | template:
13 | metadata:
14 | labels:
15 | db: rethinkdb
16 | role: replicas
17 | spec:
18 | containers:
19 | - image: k8s.gcr.io/rethinkdb:1.16.0_1
20 | name: rethinkdb
21 | env:
22 | - name: POD_NAMESPACE
23 | valueFrom:
24 | fieldRef:
25 | fieldPath: metadata.namespace
26 | ports:
27 | - containerPort: 8080
28 | name: admin-port
29 | - containerPort: 28015
30 | name: driver-port
31 | - containerPort: 29015
32 | name: cluster-port
33 | volumeMounts:
34 | - mountPath: /data/rethinkdb_data
35 | name: rethinkdb-storage
36 | volumes:
37 | - name: rethinkdb-storage
38 | emptyDir: {}
39 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/vtctld-down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # This is an example script that stops vtctld.
18 |
19 | set -e
20 |
21 | script_root=`dirname "${BASH_SOURCE}"`
22 | source $script_root/env.sh
23 |
24 | echo "Deleting vtctld replicationcontroller..."
25 | $KUBECTL delete replicationcontroller vtctld
26 |
27 | echo "Deleting vtctld service..."
28 | $KUBECTL delete service vtctld
29 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/vtgate-down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # This is an example script that stops vtgate.
18 |
19 | set -e
20 |
21 | script_root=`dirname "${BASH_SOURCE}"`
22 | source $script_root/env.sh
23 |
24 | echo "Deleting vtgate replicationcontroller..."
25 | $KUBECTL delete replicationcontroller vtgate
26 |
27 | echo "Deleting vtgate service..."
28 | $KUBECTL delete service vtgate
29 |
--------------------------------------------------------------------------------
/examples/guestbook-go/redis-master-controller.json:
--------------------------------------------------------------------------------
1 | {
2 | "kind":"ReplicationController",
3 | "apiVersion":"v1",
4 | "metadata":{
5 | "name":"redis-master",
6 | "labels":{
7 | "app":"redis",
8 | "role":"master"
9 | }
10 | },
11 | "spec":{
12 | "replicas":1,
13 | "selector":{
14 | "app":"redis",
15 | "role":"master"
16 | },
17 | "template":{
18 | "metadata":{
19 | "labels":{
20 | "app":"redis",
21 | "role":"master"
22 | }
23 | },
24 | "spec":{
25 | "containers":[
26 | {
27 | "name":"redis-master",
28 | "image":"redis:2.8.23",
29 | "ports":[
30 | {
31 | "name":"redis-server",
32 | "containerPort":6379
33 | }
34 | ]
35 | }
36 | ]
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/examples/guestbook/php-redis/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Guestbook
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
Guestbook
12 |
18 |
19 |
20 | {{msg}}
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/guestbook-down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # This is an example script that stops guestbook.
18 |
19 | set -e
20 |
21 | script_root=`dirname "${BASH_SOURCE}"`
22 | source $script_root/env.sh
23 |
24 | echo "Deleting guestbook replicationcontroller..."
25 | $KUBECTL delete replicationcontroller guestbook
26 |
27 | echo "Deleting guestbook service..."
28 | $KUBECTL delete service guestbook
29 |
--------------------------------------------------------------------------------
/examples/guestbook-go/redis-slave-controller.json:
--------------------------------------------------------------------------------
1 | {
2 | "kind":"ReplicationController",
3 | "apiVersion":"v1",
4 | "metadata":{
5 | "name":"redis-slave",
6 | "labels":{
7 | "app":"redis",
8 | "role":"slave"
9 | }
10 | },
11 | "spec":{
12 | "replicas":2,
13 | "selector":{
14 | "app":"redis",
15 | "role":"slave"
16 | },
17 | "template":{
18 | "metadata":{
19 | "labels":{
20 | "app":"redis",
21 | "role":"slave"
22 | }
23 | },
24 | "spec":{
25 | "containers":[
26 | {
27 | "name":"redis-slave",
28 | "image":"kubernetes/redis-slave:v2",
29 | "ports":[
30 | {
31 | "name":"redis-server",
32 | "containerPort":6379
33 | }
34 | ]
35 | }
36 | ]
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/examples/staging/openshift-origin/openshift-controller.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | labels:
5 | name: openshift
6 | name: openshift
7 | spec:
8 | selector:
9 | matchLabels:
10 | name: openshift
11 | replicas: 1
12 | selector:
13 | matchLabels:
14 | name: openshift
15 | template:
16 | metadata:
17 | labels:
18 | name: openshift
19 | spec:
20 | containers:
21 | - args:
22 | - start
23 | - master
24 | - --config=/config/master-config.yaml
25 | image: "openshift/origin"
26 | name: origin
27 | ports:
28 | - containerPort: 8443
29 | name: openshift
30 | volumeMounts:
31 | - mountPath: /config
32 | name: config
33 | readOnly: true
34 | volumes:
35 | - name: config
36 | secret:
37 | secretName: openshift-config
38 |
--------------------------------------------------------------------------------
/examples/staging/podsecuritypolicy/rbac/policies.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: policy/v1beta1
2 | kind: PodSecurityPolicy
3 | metadata:
4 | name: privileged
5 | spec:
6 | fsGroup:
7 | rule: RunAsAny
8 | privileged: true
9 | runAsUser:
10 | rule: RunAsAny
11 | seLinux:
12 | rule: RunAsAny
13 | supplementalGroups:
14 | rule: RunAsAny
15 | volumes:
16 | - '*'
17 | allowedCapabilities:
18 | - '*'
19 | hostPID: true
20 | hostIPC: true
21 | hostNetwork: true
22 | hostPorts:
23 | - min: 1
24 | max: 65536
25 | ---
26 | apiVersion: policy/v1beta1
27 | kind: PodSecurityPolicy
28 | metadata:
29 | name: restricted
30 | spec:
31 | privileged: false
32 | fsGroup:
33 | rule: RunAsAny
34 | runAsUser:
35 | rule: MustRunAsNonRoot
36 | seLinux:
37 | rule: RunAsAny
38 | supplementalGroups:
39 | rule: RunAsAny
40 | volumes:
41 | - 'emptyDir'
42 | - 'secret'
43 | - 'downwardAPI'
44 | - 'configMap'
45 | - 'persistentVolumeClaim'
46 | - 'projected'
47 | hostPID: false
48 | hostIPC: false
49 | hostNetwork: false
50 |
--------------------------------------------------------------------------------
/examples/staging/storm/storm-worker-controller.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: storm-worker-controller
5 | labels:
6 | name: storm-worker
7 | spec:
8 | replicas: 2
9 | selector:
10 | matchLabels:
11 | name: storm-worker
12 | uses: nimbus
13 | template:
14 | metadata:
15 | labels:
16 | name: storm-worker
17 | uses: nimbus
18 | spec:
19 | containers:
20 | - name: storm-worke
21 | image: mattf/storm-worker
22 | resources:
23 | limits:
24 | cpu: 200m
25 | memory: 500Mi
26 | requests:
27 | cpu: 100m
28 | memory: 100Mi
29 | ports:
30 | - hostPort: 6700
31 | containerPort: 6700
32 | - hostPort: 6701
33 | containerPort: 6701
34 | - hostPort: 6702
35 | containerPort: 6702
36 | - hostPort: 6703
37 | containerPort: 6703
38 |
--------------------------------------------------------------------------------
/examples/staging/volumes/nfs/nfs-data/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM centos
16 | RUN yum -y install /usr/bin/ps nfs-utils && yum clean all
17 | RUN mkdir -p /exports
18 | ADD run_nfs.sh /usr/local/bin/
19 | ADD index.html /tmp/index.html
20 | RUN chmod 644 /tmp/index.html
21 |
22 | # expose mountd 20048/tcp and nfsd 2049/tcp and rpcbind 111/tcp
23 | EXPOSE 2049/tcp 20048/tcp 111/tcp 111/udp
24 |
25 | ENTRYPOINT ["/usr/local/bin/run_nfs.sh", "/exports"]
26 |
--------------------------------------------------------------------------------
/examples/guestbook/frontend-deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: frontend
5 | spec:
6 | selector:
7 | matchLabels:
8 | app: guestbook
9 | tier: frontend
10 | replicas: 3
11 | template:
12 | metadata:
13 | labels:
14 | app: guestbook
15 | tier: frontend
16 | spec:
17 | containers:
18 | - name: php-redis
19 | image: gcr.io/google-samples/gb-frontend:v4
20 | resources:
21 | requests:
22 | cpu: 100m
23 | memory: 100Mi
24 | env:
25 | - name: GET_HOSTS_FROM
26 | value: dns
27 | # If your cluster config does not include a dns service, then to
28 | # instead access environment variables to find service host
29 | # info, comment out the 'value: dns' line above, and uncomment the
30 | # line below:
31 | # value: env
32 | ports:
33 | - containerPort: 80
34 |
--------------------------------------------------------------------------------
/examples/staging/selenium/selenium-node-firefox-deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: Deployment
3 | metadata:
4 | name: selenium-node-firefox
5 | labels:
6 | app: selenium-node-firefox
7 | spec:
8 | replicas: 2
9 | selector:
10 | matchLabels:
11 | app: selenium-node-firefox
12 | template:
13 | metadata:
14 | labels:
15 | app: selenium-node-firefox
16 | spec:
17 | volumes:
18 | - name: dshm
19 | emptyDir:
20 | medium: Memory
21 | containers:
22 | - name: selenium-node-firefox
23 | image: selenium/node-firefox-debug:3.11
24 | ports:
25 | - containerPort: 5900
26 | volumeMounts:
27 | - mountPath: /dev/shm
28 | name: dshm
29 | env:
30 | - name: HUB_PORT_4444_TCP_ADDR
31 | value: "selenium-hub"
32 | - name: HUB_PORT_4444_TCP_PORT
33 | value: "4444"
34 | resources:
35 | limits:
36 | memory: "1000Mi"
37 | cpu: ".5"
38 |
--------------------------------------------------------------------------------
/examples/staging/storage/rethinkdb/image/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM rethinkdb:1.16.0
16 |
17 |
18 | RUN apt-get update && \
19 | apt-get install -yq curl && \
20 | rm -rf /var/cache/apt/* && rm -rf /var/lib/apt/lists/* && \
21 | curl -L http://stedolan.github.io/jq/download/linux64/jq > /usr/bin/jq && \
22 | chmod u+x /usr/bin/jq
23 |
24 | COPY ./run.sh /usr/bin/run.sh
25 | RUN chmod u+x /usr/bin/run.sh
26 |
27 | CMD "/usr/bin/run.sh"
28 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/guestbook-up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # This is an example script that starts a guestbook replicationcontroller.
18 |
19 | set -e
20 |
21 | script_root=`dirname "${BASH_SOURCE}"`
22 | source $script_root/env.sh
23 |
24 | echo "Creating guestbook service..."
25 | $KUBECTL create -f guestbook-service.yaml
26 |
27 | echo "Creating guestbook replicationcontroller..."
28 | $KUBECTL create -f guestbook-controller.yaml
29 |
--------------------------------------------------------------------------------
/examples/guestbook-go/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Guestbook
9 |
10 |
11 |
14 |
15 |
16 |
Waiting for database connection...
17 |
18 |
19 |
25 |
26 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/staging/cpu-manager/pod-ips:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Requires `jq`. See https://stedolan.github.io/jq/download
18 |
19 | set -o nounset -o pipefail -o errexit
20 |
21 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22 | KUBECTL="$DIR/../../cluster/kubectl.sh"
23 | export KUBECONFIG="${KUBECONFIG:-/var/run/kubernetes/admin.kubeconfig}"
24 |
25 | $KUBECTL get pods -o json | \
26 | jq -r '.items[] | "\(.metadata.name) http://\(.status.podIP)"'
27 |
--------------------------------------------------------------------------------
/examples/staging/openshift-origin/etcd-discovery-controller.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: etcd-discovery
5 | spec:
6 | selector:
7 | matchLabels:
8 | name: etcd-discovery
9 | strategy:
10 | type: Recreate
11 | replicas: 1
12 | selector:
13 | matchLabels:
14 | name: etcd-discovery
15 | template:
16 | metadata:
17 | labels:
18 | name: etcd-discovery
19 | spec:
20 | containers:
21 | - name: discovery
22 | image: openshift/etcd-20-centos7
23 | args:
24 | - etcd-discovery.sh
25 | ports:
26 | - containerPort: 2379
27 | protocol: TCP
28 | resources: {}
29 | terminationMessagePath: "/dev/termination-log"
30 | imagePullPolicy: IfNotPresent
31 | securityContext:
32 | capabilities: {}
33 | privileged: false
34 | restartPolicy: Always
35 | dnsPolicy: ClusterFirst
36 | serviceAccount: ''
37 | status: {}
38 |
--------------------------------------------------------------------------------
/examples/guestbook/php-redis/controllers.js:
--------------------------------------------------------------------------------
1 | var redisApp = angular.module('redis', ['ui.bootstrap']);
2 |
3 | /**
4 | * Constructor
5 | */
6 | function RedisController() {}
7 |
8 | RedisController.prototype.onRedis = function() {
9 | this.scope_.messages.push(this.scope_.msg);
10 | this.scope_.msg = "";
11 | var value = this.scope_.messages.join();
12 | this.http_.get("guestbook.php?cmd=set&key=messages&value=" + value)
13 | .success(angular.bind(this, function(data) {
14 | this.scope_.redisResponse = "Updated.";
15 | }));
16 | };
17 |
18 | redisApp.controller('RedisCtrl', function ($scope, $http, $location) {
19 | $scope.controller = new RedisController();
20 | $scope.controller.scope_ = $scope;
21 | $scope.controller.location_ = $location;
22 | $scope.controller.http_ = $http;
23 |
24 | $scope.controller.http_.get("guestbook.php?cmd=get&key=messages")
25 | .success(function(data) {
26 | console.log(data);
27 | $scope.messages = data.data.split(",");
28 | });
29 | });
30 |
--------------------------------------------------------------------------------
/examples/guestbook/redis-slave-deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: redis-slave
5 | spec:
6 | selector:
7 | matchLabels:
8 | app: redis
9 | role: slave
10 | tier: backend
11 | replicas: 2
12 | template:
13 | metadata:
14 | labels:
15 | app: redis
16 | role: slave
17 | tier: backend
18 | spec:
19 | containers:
20 | - name: slave
21 | image: gcr.io/google_samples/gb-redisslave:v1
22 | resources:
23 | requests:
24 | cpu: 100m
25 | memory: 100Mi
26 | env:
27 | - name: GET_HOSTS_FROM
28 | value: dns
29 | # If your cluster config does not include a dns service, then to
30 | # instead access an environment variable to find the master
31 | # service's host, comment out the 'value: dns' line above, and
32 | # uncomment the line below:
33 | # value: env
34 | ports:
35 | - containerPort: 6379
36 |
--------------------------------------------------------------------------------
/examples/guestbook-go/public/style.css:
--------------------------------------------------------------------------------
1 | body, input {
2 | color: #123;
3 | font-family: "Gill Sans", sans-serif;
4 | }
5 |
6 | div {
7 | overflow: hidden;
8 | padding: 1em 0;
9 | position: relative;
10 | text-align: center;
11 | }
12 |
13 | h1, h2, p, input, a {
14 | font-weight: 300;
15 | margin: 0;
16 | }
17 |
18 | h1 {
19 | color: #BDB76B;
20 | font-size: 3.5em;
21 | }
22 |
23 | h2 {
24 | color: #999;
25 | }
26 |
27 | form {
28 | margin: 0 auto;
29 | max-width: 50em;
30 | text-align: center;
31 | }
32 |
33 | input {
34 | border: 0;
35 | border-radius: 1000px;
36 | box-shadow: inset 0 0 0 2px #BDB76B;
37 | display: inline;
38 | font-size: 1.5em;
39 | margin-bottom: 1em;
40 | outline: none;
41 | padding: .5em 5%;
42 | width: 55%;
43 | }
44 |
45 | form a {
46 | background: #BDB76B;
47 | border: 0;
48 | border-radius: 1000px;
49 | color: #FFF;
50 | font-size: 1.25em;
51 | font-weight: 400;
52 | padding: .75em 2em;
53 | text-decoration: none;
54 | text-transform: uppercase;
55 | white-space: normal;
56 | }
57 |
58 | p {
59 | font-size: 1.5em;
60 | line-height: 1.5;
61 | }
62 |
--------------------------------------------------------------------------------
/examples/staging/explorer/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | all: push
16 |
17 | # Keep this one version ahead, so no one accidentally blows away the latest published version.
18 | TAG = 1.1
19 |
20 | explorer: explorer.go
21 | CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' ./explorer.go
22 |
23 | container: explorer
24 | docker build --pull -t staging-k8s.gcr.io/explorer:$(TAG) .
25 |
26 | push: container
27 | gcloud docker -- push staging-k8s.gcr.io/explorer:$(TAG)
28 |
29 | clean:
30 | rm -f explorer
31 |
--------------------------------------------------------------------------------
/examples/guestbook/php-redis/guestbook.php:
--------------------------------------------------------------------------------
1 | 'tcp',
19 | 'host' => $host,
20 | 'port' => 6379,
21 | ]);
22 |
23 | $client->set($_GET['key'], $_GET['value']);
24 | print('{"message": "Updated"}');
25 | } else {
26 | $host = 'redis-slave';
27 | if (getenv('GET_HOSTS_FROM') == 'env') {
28 | $host = getenv('REDIS_SLAVE_SERVICE_HOST');
29 | }
30 | $client = new Predis\Client([
31 | 'scheme' => 'tcp',
32 | 'host' => $host,
33 | 'port' => 6379,
34 | ]);
35 |
36 | $value = $client->get($_GET['key']);
37 | print('{"data": "' . $value . '"}');
38 | }
39 | } else {
40 | phpinfo();
41 | } ?>
42 |
--------------------------------------------------------------------------------
/examples/guestbook-go/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM golang:1.10.0
16 | RUN go get github.com/codegangsta/negroni \
17 | github.com/gorilla/mux \
18 | github.com/xyproto/simpleredis
19 | WORKDIR /app
20 | ADD ./main.go .
21 | RUN CGO_ENABLED=0 GOOS=linux go build -o main .
22 |
23 | FROM scratch
24 | WORKDIR /app
25 | COPY --from=0 /app/main .
26 | COPY ./public/index.html public/index.html
27 | COPY ./public/script.js public/script.js
28 | COPY ./public/style.css public/style.css
29 | CMD ["/app/main"]
30 | EXPOSE 3000
31 |
--------------------------------------------------------------------------------
/examples/staging/https-nginx/auto-reload-nginx.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright 2016 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | nginx "$@"
18 | oldcksum=`cksum /etc/nginx/conf.d/default.conf`
19 |
20 | inotifywait -e modify,move,create,delete -mr --timefmt '%d/%m/%y %H:%M' --format '%T' \
21 | /etc/nginx/conf.d/ | while read date time; do
22 |
23 | newcksum=`cksum /etc/nginx/conf.d/default.conf`
24 | if [ "$newcksum" != "$oldcksum" ]; then
25 | echo "At ${time} on ${date}, config file update detected."
26 | oldcksum=$newcksum
27 | nginx -s reload
28 | fi
29 |
30 | done
31 |
--------------------------------------------------------------------------------
/examples/staging/volumes/vsphere/simple-statefulset.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | name: nginx
6 | labels:
7 | app: nginx
8 | spec:
9 | ports:
10 | - port: 80
11 | name: web
12 | clusterIP: None
13 | selector:
14 | app: nginx
15 | ---
16 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
17 | kind: StatefulSet
18 | metadata:
19 | name: web
20 | labels:
21 | app: nginx
22 | spec:
23 | serviceName: "nginx"
24 | selector:
25 | matchLabels:
26 | app: nginx
27 | replicas: 14
28 | template:
29 | metadata:
30 | labels:
31 | app: nginx
32 | spec:
33 | containers:
34 | - name: nginx
35 | image: k8s.gcr.io/nginx-slim:0.8
36 | ports:
37 | - containerPort: 80
38 | name: web
39 | volumeMounts:
40 | - name: www
41 | mountPath: /usr/share/nginx/html
42 | volumeClaimTemplates:
43 | - metadata:
44 | name: www
45 | spec:
46 | accessModes: [ "ReadWriteOnce" ]
47 | resources:
48 | requests:
49 | storage: 1Gi
50 | storageClassName: thin-disk
51 |
--------------------------------------------------------------------------------
/examples/staging/phabricator/php-phabricator/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | echo "MySQL host IP ${MYSQL_SERVICE_IP} port ${MYSQL_SERVICE_PORT}."
18 | /home/www-data/phabricator/bin/config set mysql.host $MYSQL_SERVICE_IP
19 | /home/www-data/phabricator/bin/config set mysql.port $MYSQL_SERVICE_PORT
20 | /home/www-data/phabricator/bin/config set mysql.pass $MYSQL_PASSWORD
21 |
22 | echo "Running storage upgrade"
23 | /home/www-data/phabricator/bin/storage --force upgrade || exit 1
24 |
25 | source /etc/apache2/envvars
26 | echo "Starting Apache2"
27 | apache2 -D FOREGROUND
28 |
29 |
--------------------------------------------------------------------------------
/examples/staging/https-nginx/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | all:
16 |
17 | TAG = 1.0
18 | PREFIX = bprashanth/nginxhttps
19 | KEY = /tmp/nginx.key
20 | CERT = /tmp/nginx.crt
21 | SECRET = /tmp/secret.json
22 |
23 | keys:
24 | # The CName used here is specific to the service specified in nginx-app.yaml.
25 | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $(KEY) -out $(CERT) -subj "/CN=nginxsvc/O=nginxsvc"
26 |
27 | container:
28 | docker build --pull -t $(PREFIX):$(TAG) .
29 |
30 | push: container
31 | docker push $(PREFIX):$(TAG)
32 |
33 | clean:
34 | rm $(KEY)
35 | rm $(CERT)
36 |
--------------------------------------------------------------------------------
/examples/staging/meteor/dockerbase/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM node:0.10
16 |
17 | ONBUILD WORKDIR /appsrc
18 | ONBUILD COPY . /appsrc
19 |
20 | ONBUILD RUN curl https://install.meteor.com/ | sh && \
21 | meteor build ../app --directory --architecture os.linux.x86_64 && \
22 | rm -rf /appsrc
23 | # TODO rm meteor so it doesn't take space in the image?
24 |
25 | ONBUILD WORKDIR /app/bundle
26 |
27 | ONBUILD RUN (cd programs/server && npm install)
28 | EXPOSE 8080
29 | CMD []
30 | ENV PORT 8080
31 | ENTRYPOINT MONGO_URL=mongodb://$MONGO_SERVICE_HOST:$MONGO_SERVICE_PORT /usr/local/bin/node main.js
32 |
--------------------------------------------------------------------------------
/examples/cassandra/java/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 | %-5level %date{HH:mm:ss,SSS} %msg%n
22 |
23 |
24 | DEBUG
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/staging/volumes/flocker/flocker-pod-with-rc.yml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: flocker-ghost
5 | labels:
6 | app: flocker-ghost
7 | spec:
8 | ports:
9 | # the port that this service should serve on
10 | - port: 80
11 | targetPort: 80
12 | selector:
13 | app: flocker-ghost
14 | ---
15 | apiVersion: v1
16 | kind: ReplicationController
17 | metadata:
18 | name: flocker-ghost
19 | # these labels can be applied automatically
20 | # from the labels in the pod template if not set
21 | labels:
22 | purpose: demo
23 | spec:
24 | replicas: 1
25 | template:
26 | metadata:
27 | labels:
28 | app: flocker-ghost
29 | spec:
30 | containers:
31 | - name: flocker-ghost
32 | image: ghost:0.7.1
33 | env:
34 | - name: GET_HOSTS_FROM
35 | value: dns
36 | ports:
37 | - containerPort: 2368
38 | hostPort: 80
39 | protocol: TCP
40 | volumeMounts:
41 | # name must match the volume name below
42 | - name: ghost-data
43 | mountPath: "/var/lib/ghost"
44 | volumes:
45 | - name: ghost-data
46 | flocker:
47 | datasetName: my-flocker-vol
48 |
--------------------------------------------------------------------------------
/examples/staging/selenium/selenium-test.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | from selenium import webdriver
18 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
19 |
20 | def check_browser(browser):
21 | driver = webdriver.Remote(
22 | command_executor='http://selenium-hub:4444/wd/hub',
23 | desired_capabilities=getattr(DesiredCapabilities, browser)
24 | )
25 | driver.get("http://google.com")
26 | assert "google" in driver.page_source
27 | driver.close()
28 | print("Browser %s checks out!" % browser)
29 |
30 |
31 | check_browser("FIREFOX")
32 | check_browser("CHROME")
33 |
34 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/etcd-down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # This is an example script that tears down the etcd servers started by
18 | # etcd-up.sh.
19 |
20 | set -e
21 |
22 | script_root=`dirname "${BASH_SOURCE}"`
23 | source $script_root/env.sh
24 |
25 | CELLS=${CELLS:-'test'}
26 | cells=`echo $CELLS | tr ',' ' '`
27 |
28 | # Delete replication controllers
29 | for cell in 'global' $cells; do
30 | echo "Deleting etcd replicationcontroller for $cell cell..."
31 | $KUBECTL delete replicationcontroller etcd-$cell
32 |
33 | echo "Deleting etcd service for $cell cell..."
34 | $KUBECTL delete service etcd-$cell
35 | done
36 |
37 |
--------------------------------------------------------------------------------
/examples/staging/storage/mysql-galera/image/my.cnf:
--------------------------------------------------------------------------------
1 | [client]
2 | port=3306
3 | socket=/var/run/mysqld/mysqld.sock
4 |
5 | [mysqld_safe]
6 | socket=/var/run/mysqld/mysqld.sock
7 | nice=0
8 |
9 | [mysqld]
10 | user=mysql
11 | pid-file=/var/run/mysqld/mysqld.pid
12 | socket=/var/run/mysqld/mysqld.sock
13 | port=3306
14 | basedir=/usr
15 | datadir=/var/lib/mysql
16 | tmpdir=/tmp
17 | lc-messages-dir=/usr/share/mysql
18 | skip-external-locking
19 |
20 | key_buffer=16M
21 | max_allowed_packet=16M
22 | thread_stack=192K
23 | thread_cache_size=8
24 |
25 | myisam-recover=BACKUP
26 | #max_connections=100
27 | query_cache_limit=1M
28 | query_cache_size=16M
29 | slow_query_log=1
30 | slow_query_log_file=/var/log/mysql/mysql-slow.log
31 | long_query_time=2
32 | log-queries-not-using-indexes
33 |
34 | server-id=12345
35 | log_bin=/var/log/mysql/mysql-bin.log
36 | expire_logs_days=4
37 | max_binlog_size=100M
38 |
39 | default_storage_engine=InnoDB
40 | innodb_file_per_table
41 | innodb_log_file_size=100M
42 | innodb_log_buffer_size=10M
43 | innodb_log_files_in_group=2
44 | innodb_buffer_pool_instances=4
45 | innodb_buffer_pool_size=100M
46 |
47 | [mysqldump]
48 | quick
49 | quote-names
50 | max_allowed_packet=16M
51 |
52 | [isamchk]
53 | key_buffer=16M
54 |
55 | !includedir /etc/mysql/conf.d/
56 |
--------------------------------------------------------------------------------
/examples/staging/volumes/aws_ebs/README.md:
--------------------------------------------------------------------------------
1 | This is a simple web server pod which serves HTML from an AWS EBS
2 | volume.
3 |
4 | If you did not use kube-up script, make sure that your masters have the following IAM permissions ([Amazon IAM Roles](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#create-iam-role-console)):
5 |
6 | ```shell
7 | ec2:AttachVolume
8 | ec2:DetachVolume
9 | ec2:DescribeInstances
10 | ec2:DescribeVolumes
11 | ```
12 |
13 | Create a volume in the same region as your node.
14 |
15 | Add your volume information in the pod description file aws-ebs-web.yaml then create the pod:
16 |
17 | ```shell
18 | $ kubectl create -f examples/volumes/aws_ebs/aws-ebs-web.yaml
19 | ```
20 |
21 | Add some data to the volume if is empty:
22 |
23 | ```sh
24 | $ echo "Hello World" >& /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/{Region}/{Volume ID}/index.html
25 | ```
26 |
27 | You should now be able to query your web server:
28 |
29 | ```sh
30 | $ curl
31 | $ Hello World
32 | ```
33 |
34 |
35 |
36 | []()
37 |
38 |
--------------------------------------------------------------------------------
/examples/staging/volumes/azure_disk/README.md:
--------------------------------------------------------------------------------
1 | # How to Use it?
2 |
3 | On Azure VM, create a Pod using the volume spec based on [azure](azure.yaml).
4 |
5 | In the pod, you need to provide the following information:
6 |
7 | - *diskName*: (required) the name of the VHD blob object OR the name of an Azure managed data disk if Kind is Managed.
8 | - *diskURI*: (required) the URI of the vhd blob object OR the resourceID of an Azure managed data disk if Kind is Managed.
9 | - *kind*: (optional) kind of disk. Must be one of Shared (multiple disks per storage account), Dedicated (single blob disk per storage account), or Managed (Azure managed data disk). Default is Shared.
10 | - *cachingMode*: (optional) disk caching mode. Must be one of None, ReadOnly, or ReadWrite. Default is None.
11 | - *fsType*: (optional) the filesystem type to mount. Default is ext4.
12 | - *readOnly*: (optional) whether the filesystem is used as readOnly. Default is false.
13 |
14 |
15 | Launch the Pod:
16 |
17 | ```console
18 | # kubectl create -f examples/volumes/azure_disk/azure.yaml
19 | ```
20 |
21 |
22 | []()
23 |
24 |
--------------------------------------------------------------------------------
/examples/staging/volumes/flexvolume/deploy/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright 2018 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o pipefail
19 |
20 | # TODO change to your desired driver.
21 | VENDOR=${VENDOR:-k8s}
22 | DRIVER=${DRIVER:-dummy}
23 |
24 | # Assuming the single driver file is located at /$DRIVER inside the DaemonSet image.
25 |
26 | driver_dir=$VENDOR${VENDOR:+"~"}${DRIVER}
27 | if [ ! -d "/flexmnt/$driver_dir" ]; then
28 | mkdir "/flexmnt/$driver_dir"
29 | fi
30 |
31 | tmp_driver=.tmp_$DRIVER
32 | cp "/$DRIVER" "/flexmnt/$driver_dir/$tmp_driver"
33 | mv -f "/flexmnt/$driver_dir/$tmp_driver" "/flexmnt/$driver_dir/$DRIVER"
34 |
35 | while : ; do
36 | sleep 3600
37 | done
38 |
--------------------------------------------------------------------------------
/examples/staging/volumes/storageos/storageos-pod.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Pod
3 | metadata:
4 | labels:
5 | name: redis
6 | role: master
7 | name: test-storageos-redis
8 | spec:
9 | containers:
10 | - name: master
11 | image: kubernetes/redis:v1
12 | env:
13 | - name: MASTER
14 | value: "true"
15 | ports:
16 | - containerPort: 6379
17 | resources:
18 | limits:
19 | cpu: "0.1"
20 | volumeMounts:
21 | - mountPath: /redis-master-data
22 | name: redis-data
23 | volumes:
24 | - name: redis-data
25 | storageos:
26 | # This volume must already exist within StorageOS
27 | volumeName: redis-vol01
28 | # Namespace is optional, and specifies the volume scope within
29 | # StorageOS. If no namespace is provided, it will use the namespace
30 | # of the pod. Set to `default` or leave blank if you are not using
31 | # namespaces.
32 | #namespace: test-storageos
33 | # The name of the storageos pool to use. Will use `default` if not
34 | # specified, which should be available on most StorageOS clusters.
35 | pool: default
36 | # The filesystem type to create on the volume, if required.
37 | fsType: ext4
38 |
--------------------------------------------------------------------------------
/examples/guestbook-go/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Build the guestbook-go example
16 |
17 | # Usage:
18 | # [VERSION=v3] [REGISTRY="staging-k8s.gcr.io"] make build
19 | VERSION?=v3
20 | REGISTRY?=staging-k8s.gcr.io
21 |
22 | release: clean build push clean
23 |
24 | # builds a docker image that builds the app and packages it into a minimal docker image
25 | build:
26 | docker build -t ${REGISTRY}/guestbook:${VERSION} .
27 |
28 | # push the image to an registry
29 | push:
30 | gcloud docker -- push ${REGISTRY}/guestbook:${VERSION}
31 |
32 | # remove previous images and containers
33 | clean:
34 | docker rm -f ${REGISTRY}/guestbook:${VERSION} 2> /dev/null || true
35 |
36 | .PHONY: release clean build push
37 |
--------------------------------------------------------------------------------
/examples/staging/phabricator/phabricator-controller.json:
--------------------------------------------------------------------------------
1 | {
2 | "kind": "ReplicationController",
3 | "apiVersion": "v1",
4 | "metadata": {
5 | "name": "phabricator-controller",
6 | "labels": {
7 | "name": "phabricator"
8 | }
9 | },
10 | "spec": {
11 | "replicas": 1,
12 | "selector": {
13 | "name": "phabricator"
14 | },
15 | "template": {
16 | "metadata": {
17 | "labels": {
18 | "name": "phabricator"
19 | }
20 | },
21 | "spec": {
22 | "containers": [
23 | {
24 | "name": "phabricator",
25 | "image": "fgrzadkowski/example-php-phabricator",
26 | "ports": [
27 | {
28 | "name": "http-server",
29 | "containerPort": 80
30 | }
31 | ],
32 | "env": [
33 | {
34 | "name": "MYSQL_SERVICE_IP",
35 | "value": "1.2.3.4"
36 | },
37 | {
38 | "name": "MYSQL_SERVICE_PORT",
39 | "value": "3306"
40 | },
41 | {
42 | "name": "MYSQL_PASSWORD",
43 | "value": "1234"
44 | }
45 | ]
46 | }
47 | ]
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/vtgate-up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # This is an example script that starts a vtgate replicationcontroller.
18 |
19 | set -e
20 |
21 | script_root=`dirname "${BASH_SOURCE}"`
22 | source $script_root/env.sh
23 |
24 | VTGATE_REPLICAS=${VTGATE_REPLICAS:-3}
25 | VTGATE_TEMPLATE=${VTGATE_TEMPLATE:-'vtgate-controller-template.yaml'}
26 |
27 | replicas=$VTGATE_REPLICAS
28 |
29 | echo "Creating vtgate service..."
30 | $KUBECTL create -f vtgate-service.yaml
31 |
32 | sed_script=""
33 | for var in replicas; do
34 | sed_script+="s,{{$var}},${!var},g;"
35 | done
36 |
37 | echo "Creating vtgate replicationcontroller..."
38 | cat $VTGATE_TEMPLATE | sed -e "$sed_script" | $KUBECTL create -f -
39 |
--------------------------------------------------------------------------------
/examples/staging/https-nginx/nginx-app.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: nginxsvc
5 | labels:
6 | app: nginx
7 | spec:
8 | type: NodePort
9 | ports:
10 | - port: 80
11 | protocol: TCP
12 | name: http
13 | - port: 443
14 | protocol: TCP
15 | name: https
16 | selector:
17 | app: nginx
18 | ---
19 | apiVersion: v1
20 | kind: ReplicationController
21 | metadata:
22 | name: my-nginx
23 | spec:
24 | replicas: 1
25 | template:
26 | metadata:
27 | labels:
28 | app: nginx
29 | spec:
30 | volumes:
31 | - name: secret-volume
32 | secret:
33 | secretName: nginxsecret
34 | - name: configmap-volume
35 | configMap:
36 | name: nginxconfigmap
37 | containers:
38 | - name: nginxhttps
39 | image: ymqytw/nginxhttps:1.5
40 | command: ["/home/auto-reload-nginx.sh"]
41 | ports:
42 | - containerPort: 443
43 | - containerPort: 80
44 | livenessProbe:
45 | httpGet:
46 | path: /index.html
47 | port: 80
48 | initialDelaySeconds: 30
49 | timeoutSeconds: 1
50 | volumeMounts:
51 | - mountPath: /etc/nginx/ssl
52 | name: secret-volume
53 | - mountPath: /etc/nginx/conf.d
54 | name: configmap-volume
55 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/vtctld-up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # This is an example script that starts vtctld.
18 |
19 | set -e
20 |
21 | script_root=`dirname "${BASH_SOURCE}"`
22 | source $script_root/env.sh
23 |
24 | echo "Creating vtctld service..."
25 | $KUBECTL create -f vtctld-service.yaml
26 |
27 | echo "Creating vtctld replicationcontroller..."
28 | # Expand template variables
29 | sed_script=""
30 | for var in backup_flags; do
31 | sed_script+="s,{{$var}},${!var},g;"
32 | done
33 |
34 | # Instantiate template and send to kubectl.
35 | cat vtctld-controller-template.yaml | sed -e "$sed_script" | $KUBECTL create -f -
36 |
37 | server=$(get_vtctld_addr)
38 | echo
39 | echo "vtctld address: http://$server"
40 |
41 |
--------------------------------------------------------------------------------
/examples/staging/elasticsearch/production_cluster/es-data-rc.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ReplicationController
3 | metadata:
4 | name: es-data
5 | labels:
6 | component: elasticsearch
7 | role: data
8 | spec:
9 | replicas: 1
10 | template:
11 | metadata:
12 | labels:
13 | component: elasticsearch
14 | role: data
15 | spec:
16 | serviceAccount: elasticsearch
17 | containers:
18 | - name: es-data
19 | securityContext:
20 | capabilities:
21 | add:
22 | - IPC_LOCK
23 | image: quay.io/pires/docker-elasticsearch-kubernetes:1.7.1-4
24 | env:
25 | - name: KUBERNETES_CA_CERTIFICATE_FILE
26 | value: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
27 | - name: NAMESPACE
28 | valueFrom:
29 | fieldRef:
30 | fieldPath: metadata.namespace
31 | - name: "CLUSTER_NAME"
32 | value: "myesdb"
33 | - name: NODE_MASTER
34 | value: "false"
35 | - name: HTTP_ENABLE
36 | value: "false"
37 | ports:
38 | - containerPort: 9300
39 | name: transport
40 | protocol: TCP
41 | volumeMounts:
42 | - mountPath: /data
43 | name: storage
44 | volumes:
45 | - name: storage
46 | emptyDir: {}
47 |
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | # Kubernetes Examples
2 |
3 | This directory contains a number of examples of how to run real applications
4 | with Kubernetes.
5 |
6 | Refer to the [Kubernetes documentation] for how to execute the tutorials.
7 |
8 | ### Maintained Examples
9 |
10 | Maintained Examples are expected to be updated with every Kubernetes release, to
11 | use the latest and greatest features, current guidelines and best practices,
12 | and to refresh command syntax, output, changed prerequisites, as needed.
13 |
14 | |Name | Description | Notable Features Used | Complexity Level|
15 | ------------- | ------------- | ------------ | ------------ |
16 | |[Guestbook](guestbook/) | PHP app with Redis | Deployment, Service | Beginner |
17 | |[WordPress](mysql-wordpress-pd/) | WordPress with MySQL | Deployment, Persistent Volume with Claim | Beginner|
18 | |[Cassandra](cassandra/) | Cloud Native Cassandra | Daemon Set, Stateful Set, Replication Controller | Intermediate
19 |
20 | > Note: Please add examples that are maintained to the list above.
21 |
22 | See [Example Guidelines](guidelines.md) for a description of what goes
23 | in this directory, and what examples should contain.
24 |
25 | [Kubernetes documentation]: https://kubernetes.io/docs/tutorials/
26 |
27 | ### Contributing
28 |
29 | Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.
30 |
--------------------------------------------------------------------------------
/examples/guestbook/php-redis/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM php:5-apache
16 |
17 | RUN apt-get update
18 | RUN pear channel-discover pear.nrk.io
19 | RUN pear install nrk/Predis
20 |
21 | # If the container's stdio is connected to systemd-journald,
22 | # /proc/self/fd/{1,2} are Unix sockets and apache will not be able to open()
23 | # them. Use "cat" to write directly to the already opened fds without opening
24 | # them again.
25 | RUN sed -i 's#ErrorLog /proc/self/fd/2#ErrorLog "|$/bin/cat 1>\&2"#' /etc/apache2/apache2.conf
26 | RUN sed -i 's#CustomLog /proc/self/fd/1 combined#CustomLog "|/bin/cat" combined#' /etc/apache2/apache2.conf
27 |
28 | ADD guestbook.php /var/www/html/guestbook.php
29 | ADD controllers.js /var/www/html/controllers.js
30 | ADD index.html /var/www/html/index.html
31 |
--------------------------------------------------------------------------------
/examples/guestbook/all-in-one/redis-slave.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: redis-slave
5 | labels:
6 | app: redis
7 | role: slave
8 | tier: backend
9 | spec:
10 | ports:
11 | - port: 6379
12 | selector:
13 | app: redis
14 | role: slave
15 | tier: backend
16 | ---
17 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
18 | kind: Deployment
19 | metadata:
20 | name: redis-slave
21 | spec:
22 | selector:
23 | matchLabels:
24 | app: redis
25 | role: slave
26 | tier: backend
27 | replicas: 2
28 | template:
29 | metadata:
30 | labels:
31 | app: redis
32 | role: slave
33 | tier: backend
34 | spec:
35 | containers:
36 | - name: slave
37 | image: gcr.io/google_samples/gb-redisslave:v1
38 | resources:
39 | requests:
40 | cpu: 100m
41 | memory: 100Mi
42 | env:
43 | - name: GET_HOSTS_FROM
44 | value: dns
45 | # If your cluster config does not include a dns service, then to
46 | # instead access an environment variable to find the master
47 | # service's host, comment out the 'value: dns' line above, and
48 | # uncomment the line below:
49 | # value: env
50 | ports:
51 | - containerPort: 6379
52 |
--------------------------------------------------------------------------------
/examples/staging/storage/minio/minio-standalone-deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | # This name uniquely identifies the Deployment
5 | name: minio-deployment
6 | spec:
7 | selector:
8 | matchLabels:
9 | app: minio
10 | strategy:
11 | type: Recreate
12 | template:
13 | metadata:
14 | labels:
15 | # Label is used as selector in the service.
16 | app: minio
17 | spec:
18 | # Refer to the PVC created earlier
19 | volumes:
20 | - name: storage
21 | persistentVolumeClaim:
22 | # Name of the PVC created earlier
23 | claimName: minio-pv-claim
24 | containers:
25 | - name: minio
26 | # Pulls the default Minio image from Docker Hub
27 | image: minio/minio:latest
28 | args:
29 | - server
30 | - /storage
31 | env:
32 | # Minio access key and secret key
33 | - name: MINIO_ACCESS_KEY
34 | value: "minio"
35 | - name: MINIO_SECRET_KEY
36 | value: "minio123"
37 | ports:
38 | - containerPort: 9000
39 | hostPort: 9000
40 | # Mount the volume into the pod
41 | volumeMounts:
42 | - name: storage # must match the volume name, above
43 | mountPath: "/storage"
44 |
--------------------------------------------------------------------------------
/examples/staging/elasticsearch/production_cluster/es-master-rc.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ReplicationController
3 | metadata:
4 | name: es-master
5 | labels:
6 | component: elasticsearch
7 | role: master
8 | spec:
9 | replicas: 1
10 | template:
11 | metadata:
12 | labels:
13 | component: elasticsearch
14 | role: master
15 | spec:
16 | serviceAccount: elasticsearch
17 | containers:
18 | - name: es-master
19 | securityContext:
20 | capabilities:
21 | add:
22 | - IPC_LOCK
23 | image: quay.io/pires/docker-elasticsearch-kubernetes:1.7.1-4
24 | env:
25 | - name: KUBERNETES_CA_CERTIFICATE_FILE
26 | value: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
27 | - name: NAMESPACE
28 | valueFrom:
29 | fieldRef:
30 | fieldPath: metadata.namespace
31 | - name: "CLUSTER_NAME"
32 | value: "myesdb"
33 | - name: NODE_MASTER
34 | value: "true"
35 | - name: NODE_DATA
36 | value: "false"
37 | - name: HTTP_ENABLE
38 | value: "false"
39 | ports:
40 | - containerPort: 9300
41 | name: transport
42 | protocol: TCP
43 | volumeMounts:
44 | - mountPath: /data
45 | name: storage
46 | volumes:
47 | - name: storage
48 | emptyDir: {}
49 |
--------------------------------------------------------------------------------
/examples/staging/storage/vitess/vtgate-controller-template.yaml:
--------------------------------------------------------------------------------
1 | kind: ReplicationController
2 | apiVersion: v1
3 | metadata:
4 | name: vtgate
5 | spec:
6 | replicas: {{replicas}}
7 | template:
8 | metadata:
9 | labels:
10 | component: vtgate
11 | app: vitess
12 | spec:
13 | containers:
14 | - name: vtgate
15 | image: vitess/lite:v2.0.0-alpha5
16 | volumeMounts:
17 | - name: syslog
18 | mountPath: /dev/log
19 | - name: vtdataroot
20 | mountPath: /vt/vtdataroot
21 | resources:
22 | limits:
23 | memory: "512Mi"
24 | cpu: "500m"
25 | command:
26 | - sh
27 | - "-c"
28 | - >-
29 | mkdir -p $VTDATAROOT/tmp &&
30 | chown -R vitess /vt &&
31 | su -p -c "/vt/bin/vtgate
32 | -topo_implementation etcd
33 | -etcd_global_addrs http://$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT
34 | -log_dir $VTDATAROOT/tmp
35 | -alsologtostderr
36 | -port 15001
37 | -tablet_protocol grpc
38 | -service_map 'bsonrpc-vt-vtgateservice'
39 | -cell test" vitess
40 | volumes:
41 | - name: syslog
42 | hostPath: {path: /dev/log}
43 | - name: vtdataroot
44 | emptyDir: {}
45 |
46 |
--------------------------------------------------------------------------------
/examples/staging/cluster-dns/images/frontend/client.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | import argparse
18 | import requests
19 | import socket
20 |
21 | from urlparse import urlparse
22 |
23 |
24 | def CheckServiceAddress(address):
25 | hostname = urlparse(address).hostname
26 | service_address = socket.gethostbyname(hostname)
27 | print service_address
28 |
29 |
30 | def GetServerResponse(address):
31 | print 'Send request to:', address
32 | response = requests.get(address)
33 | print response
34 | print response.content
35 |
36 |
37 | def Main():
38 | parser = argparse.ArgumentParser()
39 | parser.add_argument('address')
40 | args = parser.parse_args()
41 | CheckServiceAddress(args.address)
42 | GetServerResponse(args.address)
43 |
44 |
45 | if __name__ == "__main__":
46 | Main()
47 |
--------------------------------------------------------------------------------