Skip to content

Instantly share code, notes, and snippets.

@divyenpatel
Last active March 21, 2018 21:28
Show Gist options
  • Save divyenpatel/0ad18a6d248503e81c5b27f0cd950d98 to your computer and use it in GitHub Desktop.
Save divyenpatel/0ad18a6d248503e81c5b27f0cd950d98 to your computer and use it in GitHub Desktop.
couchbase-sc.yaml
#Create storage class for couchbase volumes.
kubectl create -f couchbase-sc.yaml
#Create couchbase service.
kubectl create -f couchbase-service.yaml
#Check the status of Couchbase app
kubectl get services
#The UI and backend services are created but nothing is accessible from master UI yet as we have just created the dns resolver.
#The Couchbase app (UI + noSQL db) is yet to be created.
# http://10.152.191.162:30197/ <port might change each time the service is deployed>
#Deploy the application
kubectl create -f couchbase-statefulset.yaml
# Check NGC to see steps VCP is taking behind the scenes to provision persistent storage based on the business
# requirements
https://10.152.191.28/vsphere-client/
#Show that application is deployed in two pods as they are two replicas
kubectl get pods
#Since your application has a lot of load, deploy one more instance of the app.
kubectl scale statefulset couchbase --replicas=3
#Check whether the application has scaled successfully.
kubectl get pods
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: couchbasesc
provisioner: kubernetes.io/vsphere-volume
parameters:
diskformat: thin
apiVersion: v1
kind: Service
metadata:
name: couchbase
labels:
app: couchbase
spec:
ports:
- port: 8091
name: couchbase
# *.couchbase.default.svc.cluster.local
clusterIP: None
selector:
app: couchbase
---
apiVersion: v1
kind: Service
metadata:
name: couchbase-ui
labels:
app: couchbase-ui
spec:
ports:
- port: 8091
name: couchbase
selector:
app: couchbase
sessionAffinity: ClientIP
type: LoadBalancer
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: couchbase
spec:
serviceName: "couchbase"
replicas: 2
template:
metadata:
labels:
app: couchbase
spec:
terminationGracePeriodSeconds: 0
containers:
- name: couchbase
image: saturnism/couchbase:k8s-petset
ports:
- containerPort: 8091
volumeMounts:
- name: couchbase-data
mountPath: /opt/couchbase/var
env:
- name: COUCHBASE_MASTER
value: "couchbase-0.couchbase.default.svc.cluster.local"
- name: AUTO_REBALANCE
value: "false"
volumeClaimTemplates:
- metadata:
name: couchbase-data
annotations:
volume.beta.kubernetes.io/storage-class: couchbasesc
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment