Skip to content

Instantly share code, notes, and snippets.

@tomoyk
Created May 31, 2022 05:24
Show Gist options
  • Save tomoyk/2a1b7862eb9020f4ccc0a2a40c1d0228 to your computer and use it in GitHub Desktop.
Save tomoyk/2a1b7862eb9020f4ccc0a2a40c1d0228 to your computer and use it in GitHub Desktop.
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
spec:
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:8.0
name: mysql-container
env:
- name: MYSQL_ROOT_PASSWORD
value: root-password
- name: MYSQL_DATABASE
value: wordpress
ports:
- containerPort: 3306
name: mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
ports:
- port: 3306
selector:
app: mysql
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress-deployment
spec:
replicas: 1
selector:
matchLabels:
app: wp
template:
metadata:
labels:
app: wp
spec:
containers:
- name: wordpress-container
image: wordpress:6.0-apache
ports:
- containerPort: 80
env:
- name: WORDPRESS_DB_HOST
value: mysql-service
- name: WORDPRESS_DB_USER
value: root
- name: WORDPRESS_DB_PASSWORD
value: root-password
---
apiVersion: v1
kind: Service
metadata:
name: wordpress-service
spec:
type: NodePort
ports:
- name: "http-port"
protocol: "TCP"
port: 8080
targetPort: 80
selector:
app: wp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment