Forked from binduchinnasamy/aspnetcore-webapp-deployment.yaml
Created
January 15, 2022 04:33
-
-
Save lualsiv/8900e9daa3d546b29c885dae898d419b to your computer and use it in GitHub Desktop.
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
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: 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 | |
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: 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 |
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: 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