Skip to content

Instantly share code, notes, and snippets.

@scothis

scothis/app.yaml Secret

Last active January 27, 2022 18:10
Show Gist options
  • Save scothis/f65bd3ec45bd42ca89b1a554442c7cdc to your computer and use it in GitHub Desktop.
Save scothis/f65bd3ec45bd42ca89b1a554442c7cdc to your computer and use it in GitHub Desktop.
---
apiVersion: kapp.k14s.io/v1alpha1
kind: Config
waitRules:
- supportsObservedGeneration: true
conditionMatchers:
- type: Ready
status: "False"
failure: true
- type: Ready
status: "True"
success: true
resourceMatchers:
- apiVersionKindMatcher: {apiVersion: servicebinding.io/v1alpha3, kind: ServiceBinding}
- supportsObservedGeneration: true
conditionMatchers:
- type: Ready
status: "False"
failure: true
- type: Ready
status: "True"
success: true
resourceMatchers:
- apiVersionKindMatcher: {apiVersion: serving.knative.dev/v1, kind: Service}
---
apiVersion: servicebinding.io/v1alpha3
kind: ServiceBinding
metadata:
annotations:
kapp.k14s.io/change-rule: "upsert before upserting example.com/workload"
name: spring-petclinic-db
spec:
# direct Secret reference is used for compatibility, but not recommended for dynamically provisioned services
service:
apiVersion: v1
kind: Secret
name: spring-petclinic-db
workload:
apiVersion: serving.knative.dev/v1
kind: Service
name: spring-petclinic
---
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: spring-petclinic
annotations:
kapp.k14s.io/change-group: example.com/workload
labels:
app: spring-petclinic
spec:
template:
metadata:
labels:
app: spring-petclinic
spec:
containers:
- name: workload
# built with paketo builder from https://github.com/spring-projects/spring-petclinic
image: scothis/petclinic:service-bindings-20200922
env:
# tell the workload to use mysql instead of the default embedded database
- name: SPRING_PROFILES_ACTIVE
value: mysql
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
# NOT PRODUCTION QUALITY
---
apiVersion: v1
kind: Secret
metadata:
name: spring-petclinic-db
type: servicebinding.io/mysql
stringData:
type: mysql
provider: mariadb
host: spring-petclinic-db
port: "3306"
database: default
# demo credentials
username: user
password: pass
---
apiVersion: v1
kind: Service
metadata:
name: spring-petclinic-db
spec:
ports:
- port: 3306
selector:
app: spring-petclinic-db
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-petclinic-db
labels:
app: spring-petclinic-db
spec:
selector:
matchLabels:
app: spring-petclinic-db
template:
metadata:
labels:
app: spring-petclinic-db
spec:
# no persistance configured, the database will be reset when the pod terminates
containers:
- image: mariadb:10.5
name: mysql
env:
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: spring-petclinic-db
key: username
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: spring-petclinic-db
key: password
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: spring-petclinic-db
key: database
- name: MYSQL_ROOT_PASSWORD
value: root
ports:
- containerPort: 3306
name: mysql
livenessProbe:
tcpSocket:
port: mysql
readinessProbe:
tcpSocket:
port: mysql
startupProbe:
tcpSocket:
port: mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment