Skip to content

Instantly share code, notes, and snippets.

@bradfordcp
Last active November 13, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradfordcp/b791d13e445e582012f19dd46d2948fb to your computer and use it in GitHub Desktop.
Save bradfordcp/b791d13e445e582012f19dd46d2948fb to your computer and use it in GitHub Desktop.
Adding Astra Service Broker to reactive petclinic
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: petclinic-backend
labels:
app: petclinic-backend
spec:
replicas: 1
selector:
matchLabels:
app: petclinic-backend
template:
metadata:
labels:
app: petclinic-backend
spec:
initContainers:
- name: bundle-decoder
image: "busybox:latest"
command:
- "/bin/sh"
- "-c"
- "cat /opt/astra/encoded_external_bundle | base64 -d > /tmp/secure-connect-bundle.zip"
volumeMounts:
- name: astra-bundle
mountPath: "/opt/astra"
readOnly: true
- name: tmp
mountPath: "/tmp"
containers:
- name: petclinic-backend
image: "datastaxdevs/petclinic-backend"
env:
- name: CASSANDRA_USE_ASTRA
value: "true"
- name: ASTRA_DB_BUNDLE
value: "/tmp/secure-connect-bundle.zip"
- name: ASTRA_DB_KEYSPACE
valueFrom:
secretKeyRef:
name: petclinicdb
key: keyspace
- name: ASTRA_DB_USERNAME
valueFrom:
secretKeyRef:
name: petclinicdb
key: username
- name: ASTRA_DB_PASSWORD
valueFrom:
secretKeyRef:
name: petclinicdb
key: password
- name: LISTENING_PORT
value: "9966"
- name: MONITORING_ENABLED
value: "true"
- name: MONITORING_PROMETHEUS
value: "true"
- name: MONITORING_METRICS
value: "true"
- name: MONITORING_LISTENING_PORT
value: "9967"
- name: DISTRIBUTED_TRACING_ENABLED
value: "true"
- name: DISTRIBUTED_TRACING_URL
value: "http://tracing-server:9411"
- name: CASSANDRA_KEYSPACE_CQL
value: "CREATE KEYSPACE IF NOT EXISTS spring_petclinic WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"
- name: CASSANDRA_KEYSPACE_CREATE
value: "false"
- name: CASSANDRA_KEYSPACE_NAME
valueFrom:
secretKeyRef:
name: petclinicdb
key: keyspace
volumeMounts:
- name: tmp
mountPath: "/tmp"
volumes:
- name: tmp
emptyDir: {}
- name: astra-bundle
secret:
secretName: petclinicdb
---
kind: Service
apiVersion: v1
metadata:
name: petclinic-backend
spec:
#type: NodePort
selector:
app: petclinic-backend
ports:
# Default port used by the image
- port: 9966
#targetPort: 9966
#nodePort: 30000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: petclinic-frontend
labels:
app: petclinic-frontend
spec:
replicas: 1
selector:
matchLabels:
app: petclinic-frontend
template:
metadata:
labels:
app: petclinic-frontend
spec:
containers:
- name: petclinic-frontend
image: "datastaxdevs/petclinic-frontend"
#command: ["tail"]
#args: ["-f", "/dev/null"]
---
kind: Service
apiVersion: v1
metadata:
name: petclinic-frontend
spec:
selector:
app: petclinic-frontend
ports:
- port: 8081
targetPort: 8080
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: petclinic-ingress
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: petclinic-frontend
servicePort: 8081
- path: /petclinic/api
backend:
serviceName: petclinic-backend
servicePort: 9966
---
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceBinding
metadata:
name: petclinicdb
spec:
instanceRef:
name: petclinicdb
parameters: {}
secretName: petclinicdb
---
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
name: petclinicdb
namespace: default
spec:
parameters:
capacity_units: 1
cloud_provider: GCP
keyspace: petclinic
region: us-east1
serviceClassExternalName: astra-database
servicePlanExternalName: developer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment