Skip to content

Instantly share code, notes, and snippets.

@sri-teja
Created August 30, 2020 10:40
Show Gist options
  • Save sri-teja/5ae6bffa0f143395889b2923e5b33a8a to your computer and use it in GitHub Desktop.
Save sri-teja/5ae6bffa0f143395889b2923e5b33a8a to your computer and use it in GitHub Desktop.
Kubernetes Deployment and Service .yaml template
## Author: Sri Teja
## Description: Kubernetes Deployment and Service deployment.yaml template for my projects
## Variables ##
## app_name: Your project name
## host_name: Your database Host Name (localhost/ AWS RDS URL ...)
## image_name: Your image reference to build container (from docker registery/ AWS ECR Image URL ...)
apiVersion: v1
kind: Service
metadata:
name: {{app_name}-service
spec:
selector:
app: {{app_name}
ports:
- protocol: "TCP"
name: nginx
port: 80
targetPort: 80
- protocol: "TCP"
name: https
port: 443
targetPort: 443
- protocol: "TCP"
name: phpmyadmin
port: 8080
targetPort: 8080
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{app_name}
spec:
selector:
matchLabels:
app: {{app_name}}
replicas: 1
template:
metadata:
labels:
app: {{app_name}}
spec:
containers:
- name: api
image: {{image_name}
ports:
- containerPort: 8081
imagePullPolicy: Always
- name: nginx
image: {{image_name}
ports:
- containerPort: 80
- containerPort: 443
imagePullPolicy: Always
- name: phpmyadmin
image: bitnami/phpmyadmin
ports:
- containerPort: 8080
env:
- name: DATABASE_HOST
value: {{host_name}
- name: DATABASE_PORT_NUMBER
value: "3306"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment