We recently announced the latest preview of the Couchbase Autonomous Operator (CAO) 2.0 beta. This release is a significant update to the Couchbase Autonomous Operator. Couchbase Autonomous Operator 2.0 introduces several new enterprise-grade features with fully autonomous capabilities – security, monitoring, high-availability, and manageability. In this blog, we will examine in-depth how one of those works.
Coleção de métricas da Prometheus
O operador mais recente oferece integração nativa com o Couchbase Prometheus Exporter para coletar e expor as métricas do Couchbase Server. Essas métricas exportadas podem ser extraídas pelo Prometheus e, em seguida, visualizadas em ferramentas como o Grafana.
We will describe the steps to deploy the cluster with the Couchbase Prometheus Exporter and look at some of the metrics through Grafana. This will be a simple single cluster test deployment and will not detail all the other necessary steps for a production level deployment.
We will be closely following the Couchbase Autonomous Operator 2.0 Beta tutorial on installing on Amazon EKS.
Pré-requisitos
I assume you already have an Amazon Virtual Private Cloud (VPC) to use. Follow the documentation on Getting Started with Amazon EKS and install the following:
Arquitetura de implantação
A quick overview of the architecture of our deployment.
Referring the above diagram:
1: Create the Kubernetes cluster on Amazon EKS. The cluster manages Kubernetes Resources and Services.
2: Add Couchbase Resources by installing the Couchbase Custom Resource Definitions.
3: Install the Couchbase Autonomous Operator. This creates 2 Pods, the Operator and the Admission Controller in the Default namespace.
4: Deploy a 3 node Couchbase Cluster in the Default namespace. This creates 3 pods, each pod has a Couchbase 6.5.0 container and a Couchbase Metrics Exporter container.
5: Create a ServiceMonitor which tells Prometheus to monitor a Service resource that defines the endpoints Prometheus scrapes.
6: Create a Service will define the port that we described in our ServiceMonitor at earlier in the Default namespace.
7: Add Prometheus Resources by installing the Prometheus Custom Resource Definitions.
8: Create the Prometheus/Grafana Pods in the Monitoring namespace.
Create the Cluster and Configure kubectl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
$ eksctl criar agrupamento \ --nome prasadCAO2 \ --região nós-leste-1 \ --zonas nós-leste-1a,nós-leste-1b,nós-leste-1c \ --nógrupo-nome padrão-trabalhadores \ --nó-tipo t3.medium \ --nós 3 \ --nós-min 1 \ --nós-máximo 4 \ --ssh-acesso \ --ssh-público-chave ~/couchbase-prasad.pub \ --gerenciado [ℹ] eksctl versão 0.16.0 [ℹ] usando região nós-leste-1 [ℹ] subnets para nós-leste-1a - público:192.168.0.0/19 privado:192.168.96.0/19 [ℹ] subnets para nós-leste-1b - público:192.168.32.0/19 privado:192.168.128.0/19 [ℹ] subnets para nós-leste-1c - público:192.168.64.0/19 privado:192.168.160.0/19 [ℹ] usando SSH público chave "/Users/krishna.doddi/couchbase-prasad.pub" como "eksctl-prasadCAO2-nodegroup-standard-workers-42:57:cd:cb:28:33:4a:d9:59:4e:73:3b:c0:e8:a3:fe" [ℹ] usando Kubernetes versão 1.14 [ℹ] criando EKS agrupamento "prasadCAO2" em "us-east-1" região com gerenciado nós [ℹ] vontade criar 2 separado CloudFormation pilhas para agrupamento em si e o inicial gerenciado nógrupo [ℹ] se você encontro qualquer problemas, verificar CloudFormation console ou tentar 'eksctl utils describe-stacks --region=us-east-1 --cluster=prasadCAO2' [ℹ] CloudWatch registro vontade não ser habilitado para agrupamento "prasadCAO2" em "us-east-1" [ℹ] você pode ativar ele com 'eksctl utils update-cluster-logging --region=us-east-1 --cluster=prasadCAO2' [ℹ] Kubernetes API ponto final acesso vontade uso padrão de {publicAccess=verdadeiro, privateAccess=falso} para agrupamento "prasadCAO2" em "us-east-1" [ℹ] 2 sequencial tarefas: { criar agrupamento controle avião "prasadCAO2", criar gerenciado nógrupo "standard-workers" } [ℹ] construção agrupamento pilha "eksctl-prasadCAO2-cluster" [ℹ] implantação pilha "eksctl-prasadCAO2-cluster" [ℹ] construção gerenciado nógrupo pilha "eksctl-prasadCAO2-nodegroup-standard-workers" [ℹ] implantação pilha "eksctl-prasadCAO2-nodegroup-standard-workers" [✔] todos EKS agrupamento recursos para "prasadCAO2" ter foram criado [✔] salvos kubeconfig como "/Users/krishna.doddi/.kube/config" [ℹ] nógrupo "standard-workers" tem 3 nó(s) [ℹ] nó "ip-192-168-13-207.ec2.internal" é pronto [ℹ] nó "ip-192-168-62-181.ec2.internal" é pronto [ℹ] nó "ip-192-168-93-184.ec2.internal" é pronto [ℹ] esperando para em menos 1 nó(s) para tornar-se pronto em "standard-workers" [ℹ] nógrupo "standard-workers" tem 3 nó(s) [ℹ] nó "ip-192-168-13-207.ec2.internal" é pronto [ℹ] nó "ip-192-168-62-181.ec2.internal" é pronto [ℹ] nó "ip-192-168-93-184.ec2.internal" é pronto [ℹ] kubectl comando deve trabalho com "/Users/krishna.doddi/.kube/config", tentar 'kubectl get nodes' [✔] EKS agrupamento "prasadCAO2" em "us-east-1" região é pronto |
1 2 3 4 5 6 7 8 9 10 11 12 |
$ kubectl obter serviço NOME TIPO CLUSTER-IP EXTERNO-IP PORTO(S) IDADE kubernetes ClusterIP 10.100.0.1 <nenhum> 443/TCP 15m $ kubectl obter nós NOME STATUS PAPÉIS IDADE VERSÃO ip-192-168-13-207.ec2.internal Pronto <nenhum> 4d4h v1.14.9-eks-1f0ca9 ip-192-168-62-181.ec2.internal Pronto <nenhum> 4d4h v1.14.9-eks-1f0ca9 ip-192-168-93-184.ec2.internal Pronto <nenhum> 4d4h v1.14.9-eks-1f0ca9 |
Configure kubectl
This command is vital as it sets the relevant Amazon Resource Name (ARN) variables in ~/.kube/config
. Optionally, you can add --region regionName
to specify a cluster in a region that is different than the default. (Your default region should have been specified when you first setup the AWS CLI through aws configure
command.)
1 2 3 |
$ aws eks atualização-kubeconfig --nome prasadCAO2 Added novo contexto arn:aws:eks:nós-leste-1:429712224361:agrupamento/prasadCAO2 para /Usuários/krishna.doddi/.cubo/configuração |
Install the Custom Resource Definitions (CRD)
Note: I downloaded the Operator for MacOS, renamed the package from couchbase-autonomous-operator-kubernetes_2.0.0-macos-x86_64 para cao-2 and cd’d into this directory.
The first step in installing the Operator is to install the custom resource definitions (CRD) that describe the Couchbase resource types.
1 2 3 4 5 6 7 8 9 10 11 12 |
cao-2 $ kubectl criar -f crd.yaml definição de recursos personalizados.apiextensões.k8s.io/couchbasebuckets.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/couchbaseephemeralbuckets.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/couchbasemcachedbuckets.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/couchbasereplications.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/usuários do couchbase.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/grupos de base de sofá.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/sofá-base-rolo-ligações.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/couchbaseclusters.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/couchbasebackups.couchbase.com criado definição de recursos personalizados.apiextensões.k8s.io/couchbasebackuprestores.couchbase.com criado |
Install the Autonomous Operator 2.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
cao-2 $ caixa/cbopcfg | kubectl criar -f - conta de serviço/couchbase-operador-admissão criado papel de agrupamento.rbac.autorização.k8s.io/couchbase-operador-admissão criado aglutinação de papéis.rbac.autorização.k8s.io/couchbase-operador-admissão criado segredo/couchbase-operador-admissão criado implantação.aplicativos/couchbase-operador-admissão criado serviço/couchbase-operador-admissão criado mutatingwebhookconfiguration.admissionregistration.k8s.io/couchbase-operador-admissão criado validando a configuração do webhook.admissionregistration.k8s.io/couchbase-operador-admissão criado conta de serviço/couchbase-operador criado função.rbac.autorização.k8s.io/couchbase-operador criado vinculação de função.rbac.autorização.k8s.io/couchbase-operador criado implantação.aplicativos/couchbase-operador criado serviço/couchbase-operador criado |
Check the status of the Operator
1 2 3 4 5 |
cao-2 $ kubectl obter implantações NOME PRONTO UP-PARA-DATA DISPONÍVEL IDADE couchbase-operador 1/1 1 1 96s couchbase-operador-admissão 1/1 1 1 97s |
The Operator is ready to deploy CouchbaseCluster resources when both the Dynamic Admission Controller (couchbase-operator-admission) and Operator (couchbase-operator) deployments are fully ready and available.
Prepare the Couchbase Cluster Configuration
I’ll deploy a 3 node Couchbase Server 6.5.0 Cluster with Prometheus Couchbase Exporter. For this, I created my-cluster.yaml file in the current directory. This is just my sample. Here is the file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
Versão da API: v1 gentil: Secreto metadados: nome: cb-exemplo-autenticação tipo: Opaco dados: nome de usuário: QWRtaW5pc3RyYXRvcg== Administrador # senha: cGFzc3dvcmQ= Senha # --- Versão da API: couchbase.com/v2 gentil: CouchbaseCluster metadados: nome: cb-exemplo especificação: imagem: couchbase/servidor:6.5.0 segurança: adminSecret: cb-exemplo-autenticação pausado: falso antiAffinity: verdadeiro softwareUpdateNotifications: verdadeiro Grupos de servidores: - nós-leste-1a - nós-leste-1b - nós-leste-1c securityContext: runAsUser: 1000 runAsNonRoot: verdadeiro fsGroup: 1000 plataforma: aws agrupamento: clusterName: cb-exemplo DataServiceMemoryQuota: 512Mi indexServiceMemoryQuota: 256Mi searchServiceMemoryQuota: 256Mi indexStorageSetting: memória_otimizado autoFailoverTimeout: 120s autoFailoverMaxCount: 3 autoFailoverOnDataDiskIssues: verdadeiro autoFailoverOnDataDiskIssuesTimePeriod: 120s autoFailoverServerGroup: falso autoCompaction: databaseFragmentationThreshold: por cento: 30 tamanho: 1Gi viewFragmentationThreshold: por cento: 30 tamanho: 1Gi parallelCompaction: falso timeWindow: iniciar: 02:00 final: 06:00 abortCompactionOutsideWindow: verdadeiro tombstonePurgeInterval: 72h servidores: - tamanho: 3 nome: todos_serviços serviços: - dados - índice - consulta - pesquisa baldes: gerenciado: falso seletor: matchLabels: agrupamento: cb-exemplo monitoramento: prometeu: habilitado: verdadeiro imagem: couchbase/exportador:1.0.1 recursos: solicitações: CPU: 100m memória: 100Mi |
Observações:
- I have used only a minimum set of configuration parameters. Please refer to the Couchbase Cluster Resource documentation for a complete list.
- Included the secrets section in the same file to keep things simple.
- Used only the Data, Query, Index and Search services.
- Managing my own buckets instead of leaving it to the Operator.
- Make a note of the cluster label cb-exemplo as this will be used by Prometheus to discover the service later.
Dica: Make sure that buckets.managed is set to false. Otherwise, if you create a bucket manually once the cluster is up and running, Kubernetes will automatically drop it.
Implantar o cluster do Couchbase
1 2 3 4 |
cao-2 $ kubectl criar -f meu-agrupamento.yaml segredo/cb-exemplo-autenticação criado conjunto de sofás.couchbase.com/cb-exemplo criado |
Both the secret as well as the cluster are created. This does not mean they are up and running yet, for that you will have to verify as described in the next step.
Verify the deployment
1 2 3 4 5 6 7 8 |
cao-2 $ kubectl obter cápsulas NOME PRONTO STATUS RESTARTS IDADE cb-exemplo-0000 2/2 Em execução 0 9m5s cb-exemplo-0001 2/2 Em execução 0 8m53s cb-exemplo-0002 2/2 Em execução 0 8m42s couchbase-operador-5c4bd54bbf-fcj9m 1/1 Em execução 0 10m couchbase-operador-admissão-6789cd5847-w9rfd 1/1 Em execução 0 10m |
Make sure that all the pods are Pronto e Em execução. In case there is some problem, you can get the logs from the Operator.
Optional: Get the Logs
If you encounter any problems in the previous step, you can check the logs as shown below.
1 2 3 4 5 6 7 8 |
cao-2 $ kubectl registros couchbase-operador-5c4bd54bbf-fcj9m {"nível":"info","ts":1586879846.061044,"registrador":"principal","msg":"couchbase-operator","versão":"2.0.0","revisão":"release"} ...... {"nível":"info","ts":1586879986.2216492,"registrador":"cluster","msg":"Pod added to cluster","cluster":"default/cb-example","name" (nome):"cb-example-0002"} {"nível":"info","ts":1586879987.0798743,"registrador":"couchbaseutil","msg":"Rebalanceamento","cluster":"default/cb-example","progresso":0} {"nível":"info","ts":1586879993.087347,"registrador":"cluster","msg":"Rebalance completed successfully" (Rebalanceamento concluído com sucesso),"cluster":"default/cb-example"} {"nível":"info","ts":1586879993.124682,"registrador":"cluster","msg":"Reconciliação concluída","cluster":"default/cb-example"} |
Here, the Couchbase cluster deployed without any errors.
Optional: Examine a Couchbase pod.
Let’s describe a Couchbase pod to check what its running.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
cao-2 $ kubectl descrever cápsula cb-exemplo-0000 Nome: cb-exemplo-0000 Namespace: padrão ... Rótulos: aplicativo=couchbase cluster de base de sofá=cb-exemplo ... {"containers":[{"name" (nome):"couchbase-server","imagem":"couchbase/server:6.5.0","portas":[{"name" (nome):"admin","containerPort":8091,"protocolo":"TCP"} ... servidor.couchbase.com/versão: 6.5.0 Status: Em execução ... Controlled Por: CouchbaseCluster/cb-exemplo Contêineres: couchbase-servidor: Contêineres ID: doca://7b0e5df433582ad432114248fdce922fd92f63435b110265b823c013fea8c2ac Imagem: couchbase/servidor:6.5.0 ... Estado: Em execução ... métricas: Contêineres ID: doca://b4406ec41d2119978971c8fa41fb8077ace782611298ba23d254a0d4383ab5ca Imagem: couchbase/exportador:1.0.0 Imagem ID: ... Porto: 9091/TC ... Estado: Em execução |
From the output above, we see that each Couchbase pod is running 2 containers. The first is running Couchbase Server 6.5.0 and and the other is running the Couchbase Prometheus Exporter which is using Port 9091.
Access the Couchbase Administration UI
In an actual production environment, you would typically deploy using DNS and a LoadBalancer acting as the proxy and would access Couchbase UI securely, with SSL using DNS SRV records. Since we are in a test environment, we will access the Couchbase UI directly from Port 8091. We do need one more step to achieve this and that is Port Forwarding.
Port Forwarding
1 2 3 4 |
cao-2 $ kubectl porto-avançar cb-exemplo-0000 8091 & [1] 11375 cao-2 $ Encaminhamento de 127.0.0.1:8091 -> 8091 Encaminhamento de [::1]:8091 -> 8091 |
We now have deployed three pods, however, it’s enough to port forward from one pod to access the Couchbase Admin UI.
Access the UI

http://localhost:8091
Create the buckets

Add sample bucket and create pillow bucket
Run a workload to generate some metrics
Usaremos cbc-pillowfight to generate the workload. Luckily, this is bundled along with the Operator and lets deploy this. Let’s make a minor modification to the YAML file first, so that it doesn’t stop with loading the data but performs operations on the bucket. We will use the pillow bucket we just created.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Versão da API: batch/v1 gentil: Job metadados: nome: pillowfight especificação: modelo: metadados: nome: pillowfight especificação: contêineres: - nome: pillowfight imagem: sequoiatools/pillowfight:v5.0.1 comando: ["cbc-pillowfight", "-U", "couchbase://cb-example-0000.cb-example.default.svc/pillow?select_bucket=true", "-I", "10000", "-B", "1000", "-c", "10000", "-t", "1", "-u", "Administrador", "-P", "senha"] restartPolicy: Never |
Change the bucket from default to pillow and changed the -c (number of loops) option from 10 to 10,000.
Then:
1 2 |
cao-2 $ kubectl criar -f briga de travesseiros-dados-carregador.yaml trabalho.lote/briga de travesseiros criado |
Testing Prometheus and Grafana locally
We now have a three node Couchbase Cluster with the Prometheus Couchbase Exporter. The Exporter is scraping Couchbase metrics to Port 9091. Now, we could forward that port just like we forwarded port 8091 to access the Couchbase Web Console UI from our desktop. With that forwarded port, we could then have Prometheus and Grafana running in Docker containers on the desktop and use the forwarded 9091 port to get the metrics into Prometheus and visualize it in Grafana.
With the above approach, there is a limitation. First is, we would have to forward port 9091 from all 3 nodes and those node names would be hardcoded. Hardcoding node names is a huge problem in a Kubernetes environment. Moreover, you would really not be doing port forwarding in a Production environment, where you would be typically deploying with DNS and would use the DNS SRV to connect to the cluster. Finally, its best practice to run Prometheus and Grafana in Kubernetes itself, aligning with the Cloud Native paradigm.
Próximas etapas
Em Parte 2, we will be doing just that, apart from DNS since we still want to keep this as simple as possible for quick testing.
Recursos:
- Faça o download do Couchbase Autonomous Operator 2.0 Beta para Kubernetes
- Introdução ao Couchbase Autonomous Operator 2.0 Beta
- Tutorial – Operador autônomo do Couchbase no EKS
- Compartilhe suas ideias sobre o Fóruns do Couchbase
Thanks Prasad for sharing. May I ask what are the key metrics to monitor to decide when to scale-out the cluster and is it possible to configure auto-scaling of couchbase cluster in K8s?
Saudações