Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample: Kubernetes deployment file to deploy MySQL DB with persistence storage, deploy PHP MyAdmin tool to manage data in MySQL DB and a sample ASP.NET Core web application that interacts with MySQLDB
apiVersion: v1
kind: Service
metadata:
name: aspnetcore
labels:
name: aspnetcore
owner: Bindu
spec:
type: NodePort
ports:
- port: 8001
targetPort: 80
selector:
app: aspnetcore
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: aspnetcore
labels:
name: aspnetcore
spec:
selector:
matchLabels:
app: aspnetcore
template:
metadata:
labels:
app: aspnetcore
owner: Bindu
spec:
containers:
- image: bindukaladeepan/corewebappsimple:3.0
name: corewebappsimple
env:
# This will help in displaying full error
- name: ASPNETCORE_ENVIRONMENT
value: Development
- name: MYSQLCONNECTION
value: server=db;port=3306;database=sakila;user=root;password=bindu123
ports:
- containerPort: 80
restartPolicy: Always
apiVersion: v1
kind: Service
metadata:
name: db
spec:
ports:
- port: 3306
selector:
app: mysql
clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
owner: Bindu
spec:
containers:
- image: mysql:latest
name: mysql
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
value: bindu123
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
apiVersion: v1
kind: Service
metadata:
name: phpmyadmin
labels:
name: phpmyadmin
owner: Bindu
spec:
type: NodePort
ports:
- port: 80
selector:
app: phpmyadmin
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: phpmyadmin
labels:
name: phpmyadmin
spec:
selector:
matchLabels:
app: phpmyadmin
template:
metadata:
labels:
app: phpmyadmin
owner: Bindu
spec:
containers:
- image: phpmyadmin/phpmyadmin:latest
name: phpmyadmin
ports:
- containerPort: 80
restartPolicy: Always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment