Home Explore Blog CI



kubernetes

7th chunk of `content/en/blog/_posts/2016-08-00-Create-Couchbase-Cluster-Using-Kubernetes.md`
f494554663092d99ba8742494c401fe1a0ab2fcb4b58e4a90000000100000888
![](https://lh5.googleusercontent.com/kj-v_sgXzeFTY_Dm6IZyTbZ6QgRKn_zIxqsCmpVqlaykOMvVejgiRvvyAs1qyqDWMJDya58XBtWBQJrd04XHp7VfQ_SdzssmfwzRvodwynIXqqJLT_NPsBbJ7soJSeswynFFUvVk)


This shows the travel-sample bucket is created and has 31,591 JSON documents.  

**Create Couchbase “worker” Replication Controller**  
Now, let’s create a worker replication controller. It can be created using the configuration file:

```
apiVersion: v1  
kind: ReplicationController  
metadata:  
  name: couchbase-worker-rc  
spec:  
  replicas: 1  
  selector:  
    app: couchbase-worker-pod  
  template:  
    metadata:  
      labels:  
        app: couchbase-worker-pod  
    spec:  
      containers:  
      - name: couchbase-worker  
        image: arungupta/couchbase:k8s  
        env:  
          - name: TYPE  
            value: "WORKER"  
          - name: COUCHBASE\_MASTER  
            value: "couchbase-master-service"  
          - name: AUTO\_REBALANCE  
            value: "false"  
        ports:  
        - containerPort: 8091
 ```



This RC also creates a single replica of Couchbase using the same arungupta/couchbase:k8s image. The key differences here are:  

- TYPE environment variable is set to WORKER. This adds a worker Couchbase node to be added to the cluster.
- COUCHBASE\_MASTER environment variable is passed the value of couchbase-master-service. This uses the service discovery mechanism built into Kubernetes for pods in the worker and the master to communicate.
- AUTO\_REBALANCE environment variable is set to false. This ensures that the node is only added to the cluster but the cluster itself is not rebalanced. Rebalancing is required to re-distribute data across multiple nodes of the cluster. This is the recommended way as multiple nodes can be added first, and then cluster can be manually rebalanced using the Web Console.
Let’s create a worker:



```
kubectl create -f cluster-worker.yml   
replicationcontroller "couchbase-worker-rc" created
 ```







Check the RC:



```
kubectl get rc  
NAME                  DESIRED   CURRENT   AGE  
couchbase-master-rc   1         1         6m  
couchbase-worker-rc   1         1         22s
 ```

Title: Creating a Couchbase Worker Replication Controller
Summary
A Couchbase worker replication controller is created using a YAML configuration file. The key differences from the master are: the TYPE environment variable is set to WORKER, the COUCHBASE_MASTER environment variable points to the couchbase-master-service, and AUTO_REBALANCE is set to false to allow manual rebalancing after adding multiple worker nodes. The provided kubectl commands create the replication controller and verify its status.