Last active
July 31, 2018 08:21
-
-
Save IbraheemAlSaady/ba47c772cbd6914779d93fcdbe1ac0a9 to your computer and use it in GitHub Desktop.
gCloud Kubernetes Configuration
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
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
name: api-production | |
namespace: production | |
labels: | |
app: api-production | |
annotations: | |
kubernetes.io/ingress.global-static-ip-name: api-ip-production | |
spec: | |
backend: | |
serviceName: api-production | |
servicePort: 3000 | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
selector: | |
labels: | |
app: api-production | |
name: api-production | |
namespace: production | |
spec: | |
replicas: 6 | |
selector: | |
matchLabels: | |
app: api-production | |
template: | |
metadata: | |
labels: | |
app: api-production | |
spec: | |
containers: | |
- name: api-production | |
image: asia.gcr.io/project/api:latest | |
ports: | |
- containerPort: 3000 | |
env: | |
- name: PORT | |
value: "3000" | |
- name: REDIS_URL | |
value: redis://redis-master-production:6379 | |
- name: MYSQL_USER | |
valueFrom: | |
secretKeyRef: | |
name: cloudsql-db-credentials | |
key: username | |
- name: MYSQL_PASS | |
valueFrom: | |
secretKeyRef: | |
name: cloudsql-db-credentials | |
key: password | |
- name: MYSQL_DB | |
value: dbName | |
- name: MYSQL_HOST | |
value: "127.0.0.1" | |
# [START proxy_container] | |
- name: cloudsql-proxy | |
image: gcr.io/cloudsql-docker/gce-proxy:1.11 | |
command: ["/cloud_sql_proxy", "--dir=/cloudsql", | |
"-instances=project:asia-east1:db-production=tcp:3306", | |
"-credential_file=/secrets/cloudsql/credentials.json"] | |
volumeMounts: | |
- name: cloudsql-instance-credentials | |
mountPath: /secrets/cloudsql | |
readOnly: true | |
- name: ssl-certs | |
mountPath: /etc/ssl/certs | |
- name: cloudsql | |
mountPath: /cloudsql | |
# [START volumes] | |
volumes: | |
- name: cloudsql-instance-credentials | |
secret: | |
secretName: cloudsql-instance-credentials | |
- name: ssl-certs | |
hostPath: | |
path: /etc/ssl/certs | |
- name: cloudsql | |
emptyDir: | |
# [END volumes] | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
app: api-production | |
name: api-production | |
namespace: production | |
spec: | |
ports: | |
- port: 3000 | |
protocol: TCP | |
targetPort: 3000 | |
selector: | |
app: api-production | |
type: NodePort |
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
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
name: api-staging | |
namespace: staging | |
labels: | |
app: api-staging | |
annotations: | |
kubernetes.io/ingress.global-static-ip-name: api-ip-staging | |
spec: | |
backend: | |
serviceName: api-staging | |
servicePort: 3000 | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: api-staging | |
namespace: staging | |
selector: | |
labels: | |
app: api-staging | |
spec: | |
replicas: 2 | |
selector: | |
matchLabels: | |
app: api-staging | |
template: | |
metadata: | |
labels: | |
app: api-staging | |
spec: | |
containers: | |
- name: api-staging | |
image: asia.gcr.io/project/api:latest | |
ports: | |
- containerPort: 3000 | |
env: | |
- name: PORT | |
value: "3000" | |
- name: REDIS_URL | |
value: redis://redis-master-staging:6379 | |
- name: MYSQL_USER | |
valueFrom: | |
secretKeyRef: | |
name: cloudsql-db-credentials | |
key: username | |
- name: MYSQL_PASS | |
valueFrom: | |
secretKeyRef: | |
name: cloudsql-db-credentials | |
key: password | |
- name: MYSQL_DB | |
value: dbName | |
- name: MYSQL_HOST | |
value: "127.0.0.1" | |
# [START proxy_container] | |
- name: cloudsql-proxy | |
image: gcr.io/cloudsql-docker/gce-proxy:1.11 | |
command: ["/cloud_sql_proxy", "--dir=/cloudsql", | |
"-instances=project:asia-east1:db-staging=tcp:3306", | |
"-credential_file=/secrets/cloudsql/credentials.json"] | |
volumeMounts: | |
- name: cloudsql-instance-credentials | |
mountPath: /secrets/cloudsql | |
readOnly: true | |
- name: ssl-certs | |
mountPath: /etc/ssl/certs | |
- name: cloudsql | |
mountPath: /cloudsql | |
# [START volumes] | |
volumes: | |
- name: cloudsql-instance-credentials | |
secret: | |
secretName: cloudsql-instance-credentials | |
- name: ssl-certs | |
hostPath: | |
path: /etc/ssl/certs | |
- name: cloudsql | |
emptyDir: | |
# [END volumes] | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: api-staging | |
namespace: staging | |
labels: | |
app: api-staging | |
spec: | |
ports: | |
- port: 3000 | |
protocol: TCP | |
targetPort: 3000 | |
selector: | |
app: api-staging | |
type: NodePort |
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
apiVersion: v1 | |
kind: LimitRange | |
metadata: | |
name: limit-range-staging | |
namespace: staging | |
spec: | |
limits: | |
- default: | |
# default cpu limit for each container in the namespace | |
cpu: 500m | |
# default memory limit for each container in the namespace | |
memory: 400Mi | |
defaultRequest: | |
# default cpu request for each container in the namespace | |
cpu: 400m | |
# default memory request for each container in the namespace | |
memory: 400Mi | |
max: | |
# maximum cpu limit that the container could have | |
cpu: 700m | |
# maximum memory limit that the containe could have | |
memory: 500Mi | |
min: | |
# minimum cpu request that a container can have | |
cpu: 100m | |
# minimum memory request that a container can have | |
memory: 100Mi | |
type: Container |
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
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: staging | |
labels: | |
name: staging | |
--- | |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: production | |
labels: | |
name: production |
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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: redis-master-production | |
namespace: production | |
labels: | |
app: redis | |
role: master | |
tier: backend | |
spec: | |
ports: | |
- port: 6379 | |
targetPort: 6379 | |
selector: | |
app: redis | |
role: master | |
tier: backend | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: redis-master-production | |
namespace: production | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: redis | |
role: master | |
tier: backend | |
spec: | |
containers: | |
- name: master | |
image: redis | |
resources: | |
requests: | |
cpu: 100m | |
memory: 100Mi | |
ports: | |
- containerPort: 6379 |
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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: redis-master-staging | |
namespace: staging | |
labels: | |
app: redis | |
role: master | |
tier: backend | |
spec: | |
ports: | |
- port: 6379 | |
targetPort: 6379 | |
selector: | |
app: redis | |
role: master | |
tier: backend | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: redis-master-staging | |
namespace: staging | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: redis | |
role: master | |
tier: backend | |
spec: | |
containers: | |
- name: master | |
image: redis | |
resources: | |
requests: | |
cpu: 100m | |
memory: 100Mi | |
ports: | |
- containerPort: 6379 |
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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: redis-slave | |
labels: | |
app: redis | |
role: slave | |
tier: backend | |
spec: | |
ports: | |
# the port that this service should serve on | |
- port: 6379 | |
selector: | |
app: redis | |
role: slave | |
tier: backend | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: redis-slave | |
# these labels can be applied automatically | |
# from the labels in the pod template if not set | |
# labels: | |
# app: redis | |
# role: slave | |
# tier: backend | |
spec: | |
# this replicas value is default | |
# modify it according to your case | |
replicas: 2 | |
# selector can be applied automatically | |
# from the labels in the pod template if not set | |
# selector: | |
# matchLabels: | |
# app: guestbook | |
# role: slave | |
# tier: backend | |
template: | |
metadata: | |
namespace: production | |
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 | |
# If your cluster config does not include a dns service, then to | |
# instead access an environment variable to find the master | |
# service's host, comment out the 'value: dns' line above, and | |
# uncomment the line below. | |
# value: env | |
ports: | |
- containerPort: 6379 |
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
apiVersion: v1 | |
kind: ResourceQuota | |
metadata: | |
name: quota-staging | |
namespace: staging | |
spec: | |
hard: | |
requests.cpu: 1500m | |
requests.memory: 2500Mi | |
limits.cpu: 2000m | |
limits.memory: 3000Mi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment