-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added stateless app guestbook with redis (#10)
- Loading branch information
Showing
5 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- name: Deploy Sample Applications | ||
hosts: master | ||
remote_user: "{{ ansible_remote_user }}" | ||
become: yes | ||
become_method: sudo | ||
roles: | ||
- sample_apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Copy Guestbook YAML to host | ||
template: | ||
src: guestbook.yaml | ||
dest: /tmp/guestbook.yaml | ||
|
||
- name: Deploying PHP Guestbook application with Redis | ||
command: "kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /tmp/guestbook.yaml" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- import_tasks: PHPGuestbook.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: frontend | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: guestbook | ||
tier: frontend | ||
replicas: 3 | ||
template: | ||
metadata: | ||
labels: | ||
app: guestbook | ||
tier: frontend | ||
spec: | ||
containers: | ||
- name: php-redis | ||
image: gcr.io/google-samples/gb-frontend:v4 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
env: | ||
- name: GET_HOSTS_FROM | ||
value: dns | ||
# Using `GET_HOSTS_FROM=dns` requires your cluster to | ||
# provide a dns service. As of Kubernetes 1.3, DNS is a built-in | ||
# service launched automatically. However, if the cluster you are using | ||
# does not have a built-in DNS service, you can instead | ||
# instead access an environment variable to find the master | ||
# service's host. To do so, comment out the 'value: dns' line above, and | ||
# uncomment the line below: | ||
# value: env | ||
ports: | ||
- containerPort: 80 | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: frontend | ||
labels: | ||
app: guestbook | ||
tier: frontend | ||
spec: | ||
# comment or delete the following line if you want to use a LoadBalancer | ||
type: NodePort | ||
# if your cluster supports it, uncomment the following to automatically create | ||
# an external load-balanced IP for the frontend service. | ||
# type: LoadBalancer | ||
ports: | ||
- port: 80 | ||
selector: | ||
app: guestbook | ||
tier: frontend | ||
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: redis-master | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
spec: | ||
containers: | ||
- name: master | ||
image: k8s.gcr.io/redis:e2e # or just image: redis | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
ports: | ||
- containerPort: 6379 | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-master | ||
labels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
spec: | ||
ports: | ||
- port: 6379 | ||
targetPort: 6379 | ||
selector: | ||
app: redis | ||
role: master | ||
tier: backend | ||
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: redis-slave | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
replicas: 2 | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
spec: | ||
containers: | ||
- name: slave | ||
image: gcr.io/google_samples/gb-redisslave:v1 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
env: | ||
- name: GET_HOSTS_FROM | ||
value: dns | ||
# Using `GET_HOSTS_FROM=dns` requires your cluster to | ||
# provide a dns service. As of Kubernetes 1.3, DNS is a built-in | ||
# service launched automatically. However, if the cluster you are using | ||
# does not have a built-in DNS service, you can instead | ||
# instead access an environment variable to find the master | ||
# service's host. To do so, comment out the 'value: dns' line above, and | ||
# uncomment the line below: | ||
# value: env | ||
ports: | ||
- containerPort: 6379 | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-slave | ||
labels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
spec: | ||
ports: | ||
- port: 6379 | ||
selector: | ||
app: redis | ||
role: slave | ||
tier: backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters