Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2022 04:43
Show Gist options
  • Save percybolmer/160e71e5801bafd79a71d01c91dedcf1 to your computer and use it in GitHub Desktop.
Save percybolmer/160e71e5801bafd79a71d01c91dedcf1 to your computer and use it in GitHub Desktop.
K8 object for database + service.
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
namespace: hellogopher # Use the hellogopher namespace
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
value: password
ports:
- containerPort: 3306
name: mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: hellogopher # We added namespace for hellogopher
spec:
ports:
- port: 3306 # The ports to expose
selector:
app: mysql # Selector used to apply service on all Objects with label app=mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment