diff --git a/k8s/README.rst b/k8s/README.rst new file mode 100644 index 0000000..846a2cc --- /dev/null +++ b/k8s/README.rst @@ -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 diff --git a/k8s/atlas-broker-binding.yaml b/k8s/atlas-broker-binding.yaml new file mode 100644 index 0000000..65a7860 --- /dev/null +++ b/k8s/atlas-broker-binding.yaml @@ -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 diff --git a/k8s/atlas-broker-clusterservicebroker.yaml b/k8s/atlas-broker-clusterservicebroker.yaml new file mode 100644 index 0000000..ebdbb3d --- /dev/null +++ b/k8s/atlas-broker-clusterservicebroker.yaml @@ -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 diff --git a/k8s/atlas-broker-deployment.yaml b/k8s/atlas-broker-deployment.yaml new file mode 100644 index 0000000..1e9adf6 --- /dev/null +++ b/k8s/atlas-broker-deployment.yaml @@ -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 diff --git a/k8s/atlas-broker-instance.yaml b/k8s/atlas-broker-instance.yaml new file mode 100644 index 0000000..09a2d30 --- /dev/null +++ b/k8s/atlas-broker-instance.yaml @@ -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 diff --git a/k8s/atlas-broker-svc.yaml b/k8s/atlas-broker-svc.yaml new file mode 100644 index 0000000..a0ac6cb --- /dev/null +++ b/k8s/atlas-broker-svc.yaml @@ -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 diff --git a/k8s/nginx.yaml b/k8s/nginx.yaml new file mode 100644 index 0000000..00f6de8 --- /dev/null +++ b/k8s/nginx.yaml @@ -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