Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
k8s: atlas broker deployment and usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Serpieri committed Jan 8, 2018
1 parent 938b492 commit 4b9af64
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 0 deletions.
42 changes: 42 additions & 0 deletions k8s/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
k8s resources
=============

Atlas Broker Deployment
-----------------------

.. code:: bash
export NS="atlas-broker"
kubectl create ns $NS
kubectl -n $NS apply -f atlas-broker-deployment.yaml
kubectl -n $NS apply -f atlas-broker-svc.yaml
# Declaration of the broker
kubectl apply -f atlas-broker-clusterservicebroker.yaml
Test
----

Instance and Binding
^^^^^^^^^^^^^^^^^^^^

.. code:: bash
kubectl create ns test-atlas-broker
kubectl apply -f atlas-broker-instance.yaml
kubectl apply -f atlas-broker-binding.yaml
Pod
^^^

The purpose is to demonstrate how to expose secrets set by the previous binding operation.

There is 3 ways to do it:
- Individuals mapping (see env section)
- Global mapping (see envFrom section)
- File mapping (see volumeMounts/volumes)

.. code:: bash
kubectl apply -f nginx.yaml
8 changes: 8 additions & 0 deletions k8s/atlas-broker-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceBinding
metadata:
name: atlas-broker-binding
namespace: test-atlas-broker
spec:
instanceRef:
name: atlas-broker-instance
6 changes: 6 additions & 0 deletions k8s/atlas-broker-clusterservicebroker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ClusterServiceBroker
metadata:
name: atlas-broker
spec:
url: http://atlas-broker.atlas-broker.svc.cluster.local
30 changes: 30 additions & 0 deletions k8s/atlas-broker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: atlas-broker
spec:
replicas: 1
selector:
matchLabels:
project: atlas-broker
template:
metadata:
labels:
project: atlas-broker
app: atlas-broker
spec:
containers:
- env:
image: atlas-broker:1
imagePullPolicy: Always
name: atlas-broker
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 10
11 changes: 11 additions & 0 deletions k8s/atlas-broker-instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
name: atlas-broker-instance
namespace: test-atlas-broker
spec:
clusterServiceClassExternalName: atlas-mongodb-cluster
clusterServicePlanExternalName: atlas-mongodb-existing-cluster
parameters:
cluster: cluster-dev
ns: test-atlas-broker
15 changes: 15 additions & 0 deletions k8s/atlas-broker-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: atlas-broker
name: atlas-broker
spec:
ports:
- port: 80
protocol: TCP
targetPort: 5000
selector:
app: atlas-broker
sessionAffinity: None
type: ClusterIP
44 changes: 44 additions & 0 deletions k8s/nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: test-atlas-broker
labels:
app: web
spec:
containers:
- name: nginx
image: nginx
env:
- name: ATLAS_USERNAME
valueFrom:
secretKeyRef:
name: atlas-broker-binding
key: username
- name: ATLAS_PASSWORD
valueFrom:
secretKeyRef:
name: atlas-broker-binding
key: password
- name: ATLAS_DATABASE
valueFrom:
secretKeyRef:
name: atlas-broker-binding
key: database
- name: ATLAS_URI
valueFrom:
secretKeyRef:
name: atlas-broker-binding
key: uri
envFrom:
- secretRef:
name: atlas-broker-binding
volumeMounts:
- name: atlas
mountPath: "/var/run/secrets/selfservice/atlas"
readOnly: true
volumes:
- name: atlas
secret:
secretName: atlas-broker-binding
defaultMode: 256

0 comments on commit 4b9af64

Please sign in to comment.