<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dionathan Chrys on Medium]]></title>
        <description><![CDATA[Stories by Dionathan Chrys on Medium]]></description>
        <link>https://medium.com/@dionathan.chrys?source=rss-182b035d247a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*60Z48IpDOsSnoN2o</url>
            <title>Stories by Dionathan Chrys on Medium</title>
            <link>https://medium.com/@dionathan.chrys?source=rss-182b035d247a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:20:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dionathan.chrys/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Configuring HashiCorp Boundary on Kubernetes to Access Databases]]></title>
            <link>https://medium.com/totvsdevelopers/configuring-hashicorp-boundary-on-kubernetes-to-access-databases-4c453ec79bff?source=rss-182b035d247a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c453ec79bff</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[access-control]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Dionathan Chrys]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 02:29:24 GMT</pubDate>
            <atom:updated>2024-01-12T02:16:15.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="HashiCorp Boundary" src="https://cdn-images-1.medium.com/max/700/0*tF1DrLPbJvDZXNhW.png" /><figcaption>HashiCorp Boundary</figcaption></figure><h4>What is HashiCorp Boundary?</h4><p>HashiCorp Boundary can provide access to various systems through unified user identity. With just one login, it’s possible to grant access to various systems such as instances (SSH or RDP), databases, Kubernetes clusters, and even HTTP requests that require authentication.</p><h4>Advantages</h4><p>Imagine an environment where you have a PostgreSQL database, a Linux instance, and a Kubernetes cluster. Without a unified identity management, you would need to create credentials for each of these systems. However, with Boundary and a single login, you can access these systems by creating the necessary profiles and permissions.</p><h4>Let’s get started!</h4><p>I created a repository on GitHub where I implemented a Proof of Concept (POC) to access databases, thoroughly testing Boundary’s functionality.</p><p><a href="https://github.com/dionathanchrys/poc-boundary">https://github.com/dionathanchrys/poc-boundary</a></p><p>Now, let me explain how to use it on your machine, simulating three different environments. Yes, you read that correctly, we won’t use the dev mode. Instead, we’ll set up three clusters (hope your machine can handle it 🤯).</p><p>Requirements:</p><ul><li>Linux machine (Tested on Ubuntu 22.04 but compatible with other distributions)</li><li>kubectl (<a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/">Install kubectl</a>)</li><li>Docker (<a href="https://docs.docker.com/desktop/install/linux-install/">Docker Installation Guide</a>)</li><li>Kind (<a href="https://kind.sigs.k8s.io/docs/user/quick-start/#installation">Install Kind</a>)</li><li>HashiCorp Boundary 0.13 (<a href="https://developer.hashicorp.com/boundary/install#Linux">Boundary Installation</a>)</li></ul><p>After cloning the repository, execute the shell script that will create all the environments.</p><p>While in the repository’s root, run the “create-envs.sh” script located in the “app/kind-cluster/base” folder:</p><pre>app/kind-cluster/base/create-envs.sh</pre><p>It will perform the following actions:</p><ul><li>Create a Docker network for clusters to have connections between them.</li><li>Create clusters using Kind.</li><li>Apply Kubernetes manifests, creating Boundary components (controller, workers, and database) and test databases (simulating an application called <em>foo</em>).</li></ul><p>After execution, we’ll have three different clusters simulating <strong>service, development</strong> and<strong> production</strong> environments.</p><blockquote><em>Note: Between the apply of deployments and jobs, there’s the “kubectl wait” command to wait until it’s ready to proceed. It has a timeout of 120 seconds, feel free to increase it if needed.<br>Use the following command to delete everything and run the script again without any issues: “</em>docker rm -f svc-cluster-control-plane dev-cluster-control-plane prd-cluster-control-plane &amp;&amp; docker network rm cluster-kind”</blockquote><p>Confirm that the containers (clusters) are running using the command:</p><pre>❯ docker container ls<br>CONTAINER ID   IMAGE                  COMMAND                  CREATED          STATUS          PORTS                       NAMES<br>0fb7d586e3bd   kindest/node:v1.25.3   &quot;/usr/local/bin/entr…&quot;   13 minutes ago   Up 12 minutes   127.0.0.1:44133-&gt;6443/tcp   prd-cluster-control-plane<br>dca90dcb21be   kindest/node:v1.25.3   &quot;/usr/local/bin/entr…&quot;   14 minutes ago   Up 13 minutes   127.0.0.1:37027-&gt;6443/tcp   dev-cluster-control-plane<br>133d9eb5909e   kindest/node:v1.25.3   &quot;/usr/local/bin/entr…&quot;   14 minutes ago   Up 14 minutes   127.0.0.1:44399-&gt;6443/tcp   svc-cluster-control-plane</pre><p>Check the terminal output when running the Boundary migration job, it will provide the admin password and save it in the repository. Access the following address in your browser using the obtained credentials:</p><p><a href="http://192.168.222.10:32200/">http://192.168.222.10:32200</a></p><figure><img alt="Boundary Login Screen" src="https://cdn-images-1.medium.com/max/453/0*RYbpM6yVobdl5RYQ.png" /><figcaption>Boundary Login Screen</figcaption></figure><p>After logging in, go to the Workers menu, it should display the two authenticated workers.</p><figure><img alt="Workers" src="https://cdn-images-1.medium.com/max/700/0*JGdYLzCchphz8cwM.png" /><figcaption>Workers</figcaption></figure><p>Return to the Orgs menu and create a new organization (there’s already an example one for exploration). Click the ‘New Org’ button and give it a creative name.</p><figure><img alt="Creating a new Org" src="https://cdn-images-1.medium.com/max/700/0*J2LTeSSz9vmV7EeK.png" /><figcaption>Creating a new Org</figcaption></figure><p>Now, create projects within the organization (Org). Click the Projects menu and then New.</p><figure><img alt="Creating a new Project" src="https://cdn-images-1.medium.com/max/700/0*hJskyzw7zxW_SxMY.png" /><figcaption>Creating a new Project</figcaption></figure><p>Create a project for each environment for our imaginary app foo: development (dev) and production (prd).</p><figure><img alt="New projects" src="https://cdn-images-1.medium.com/max/700/0*JwRb_9EKeKv7lBV2.png" /><figcaption>New projects</figcaption></figure><p>Enter the dev project and go to Credential Store.</p><p>Insert the database credentials so that when connecting to the Target via Boundary’s CLI, it will use these credentials. (Don’t worry, we’ll see all this later.)</p><figure><img alt="Creating Credential Store" src="https://cdn-images-1.medium.com/max/700/0*mnEPDUDtHo3JUaYF.png" /><figcaption>Creating Credential Store</figcaption></figure><p>Create a Static Credential Store.</p><figure><img alt="Static Credential" src="https://cdn-images-1.medium.com/max/700/0*LXpmsQ6334h_kvTD.png" /><figcaption>Static Credential</figcaption></figure><p>After creating it, go to Credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*O1QN7_LOpUNKUN-k.png" /><figcaption>New credential</figcaption></figure><p>Insert a name, use type “Username &amp; Password,” and enter the database credentials found in the Kubernetes ConfigMap.<br><em>app/foo-postgres/overlay/dev/kustomization.yaml:linha 15</em></p><figure><img alt="Inserting credentials" src="https://cdn-images-1.medium.com/max/700/0*wflp2BDvV8-n5A6b.png" /><figcaption>Inserting credentials</figcaption></figure><figure><img alt="Credentials created" src="https://cdn-images-1.medium.com/max/700/0*7VfojZKSVNJzROVR.png" /><figcaption>Credentials created</figcaption></figure><p>Now, go to the Targets menu and then New.</p><figure><img alt="Targets" src="https://cdn-images-1.medium.com/max/1000/0*IDqg-3sExZz_Y4BX.png" /><figcaption>Targets</figcaption></figure><p>In the target addition, let’s get straight to the point!</p><ul><li><strong>Target Address:</strong> It’s shown as optional because you can configure addresses through Host Catalogs and Host Sets. However, let’s configure the address directly on the target. In this case, we’ll configure the Kubernetes database service name for dev. Run the following command to check:</li></ul><pre>❯ kubectl get services --context kind-dev-cluster -n foo-app<br>NAME               TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)    AGE<br>foo-postgres-svc   ClusterIP   10.96.45.70   &lt;none&gt;        5432/TCP   25 minutes</pre><p>The service name is “<strong>foo-postgres-svc</strong>.”, since we’re accessing from one namespace to another within the same cluster, we need to provide the complete service address, composed of “service.namespace.svc.cluster.local.” Ours will look like this: <strong>foo-postgres-svc.foo-app.svc.cluster.local</strong></p><ul><li><strong>Default Port:</strong> Port for accessing our database, in our case, it’s 5432, the default for PostgreSQL.</li></ul><figure><img alt="Creating target" src="https://cdn-images-1.medium.com/max/1000/0*ibio1eQ7PQ3hsAbJ.png" /><figcaption>Creating target</figcaption></figure><p>Further down, there’s the Workers configuration. As we have “multiple environments,” we need to configure and tell the Controller which Worker should be used to connect to the Target. This is done through the tag.</p><blockquote><em>Our structure’s design is as follows, based </em><a href="https://developer.hashicorp.com/boundary/docs/install-boundary/system-requirements#network-connectivity"><em>on this documentation page</em></a><em>:</em></blockquote><figure><img alt="Example accessing a target in the DEV environment" src="https://cdn-images-1.medium.com/max/671/0*qTDdFa1fk3izdbr4.png" /><figcaption>Example accessing a target in the DEV environment</figcaption></figure><p>Returning to the Worker tag configuration within the Target, we need to include the Worker’s tag. The tags were configured on line 17 of the DEV file:</p><p>“app/boundary-worker/overlay/dev/config/pki-worker.hcl” in DEV:</p><pre>tags {<br>  env  = [&quot;dev&quot;]<br>  type = [&quot;egress&quot;]<br>}</pre><p><a href="https://developer.hashicorp.com/boundary/docs/concepts/filtering/worker-tags">Here in the documentation</a>, you can find more details about worker tags.</p><p>In the filter, use as shown below:</p><pre>&quot;dev&quot; in &quot;/tags/env&quot;</pre><figure><img alt="Worker’s tags" src="https://cdn-images-1.medium.com/proxy/1*JdtYzqP4nueT8_GuUKoilQ.png" /><figcaption>Worker’s tags</figcaption></figure><p>After creating the target, go back to it and proceed to brokered credentials.</p><figure><img alt="Adding Brokered Credentials" src="https://cdn-images-1.medium.com/proxy/1*Y-_QbZIyK1kgz1IBSzkIlQ.png" /><figcaption>Adding Brokered Credentials</figcaption></figure><p>Associate them.</p><figure><img alt="Associating Brokered Credentials" src="https://cdn-images-1.medium.com/proxy/1*DU7xzsBj4BMJk14j5PvRvQ.png" /><figcaption>Associating Brokered Credentials</figcaption></figure><figure><img alt="Brokered Credentials Associated" src="https://cdn-images-1.medium.com/proxy/1*A_sF9bGLKuVCrDhi5dJBBQ.png" /><figcaption>Brokered Credentials Associated</figcaption></figure><p>Now, repeat the process for the PRD environment by creating credentials, the target, and associating them.</p><h4>Now, let’s see it in action!</h4><p>Now that everything is configured and okay, let’s access it. We’ll use the Boundary client CLI, we could do it through the app with an interface, but we can’t use the brokered credentials, and it would defeat the purpose of this article. Of course, we could integrate with Vault and further improve password management, but that will be for another time.</p><p>Let’s go to the terminal:</p><pre>boundary authenticate password \<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-auth-method-id ampw_eSdigWzNW1 \<br>-scope-id o_KV9tApRJlT</pre><p>Use the same credentials used to log in to the web interface.</p><p>To understand the parameters better, you can run the following command:<br>“boundary authenticate --help” or consult the documentation.</p><p>The IDs will change with each installation, to query them, follow these links:</p><ul><li>Auth Method ID: <a href="http://192.168.222.10:32200/scopes/global/auth-methods">http://192.168.222.10:32200/scopes/global/auth-methods</a></li><li>Scope ID: <a href="http://192.168.222.10:32200/scopes/global/scopes">http://192.168.222.10:32200/scopes/global/scopes</a></li></ul><p>All these parameters can be configured with environment variables, which would speed up the login process(I suggest you do this). To check the variable names, use the following commands:</p><ul><li>boundary authenticate --help</li><li>boundary authenticate password --help</li></ul><p>If you’ve logged in successfully, you’ll get the following output:</p><pre>❯boundary authenticate password \<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-scope-id o_KV9tApRJlT \<br>-auth-method-id ampw_eSdigWzNW1<br>Please enter the login name (it will be hidden): <br>Please enter the password (it will be hidden): <br><br>Authentication information:<br>  Account ID:      acctpw_nIvOD6rkRR<br>  Auth Method ID:  ampw_eSdigWzNW1<br>  Expiration Time: Tue, 16 Jan 2024 21:46:54 -03<br>  User ID:         u_d0hKJ0jcXH<br>The token was successfully stored in the chosen keyring and is not displayed here.</pre><p>Now we can connect to the target, let’s use the command:</p><pre>boundary connect postgres \<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-target-id ttcp_lwgSUO7dSG \<br>-dbname postgres</pre><p>If you want to know more, use:<br>“boundary connect --help”</p><p>If everything is successful, you’ll get the following output:</p><pre>❯ boundary connect postgres \<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-target-id ttcp_lwgSUO7dSG \<br>-dbname postgres<br>psql (14.10 (Ubuntu 14.10-0ubuntu0.22.04.1), server 13.13 (Debian 13.13-1.pgdg120+1))<br>Type &quot;help&quot; for help.<br><br>postgres=#</pre><p>This means you’re inside the database <strong>without entering credentials during login</strong> because it used the ones we associated earlier. In a real scenario, the person accessing the database won’t have contact with the credentials, you’ll need to configure roles and groups so that they only have access to the targets.</p><h4>Conclusion</h4><p>We presented a Proof of Concept (POC) where we can simulate some environments simply. However, in a real scenario where we have OIDC for login and Vault to store passwords, it becomes much more interesting.</p><p>In the future, I plan to implement more things in this POC, I’ve listed them in the repository’s issues. If you have any suggestions or encounter any issues, feel free to open an issue on <a href="https://github.com/dionathanchrys/poc-boundary/issues">GitHub</a>.</p><p>I hope I’ve helped you in some way, if you have any questions, leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c453ec79bff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/totvsdevelopers/configuring-hashicorp-boundary-on-kubernetes-to-access-databases-4c453ec79bff">Configuring HashiCorp Boundary on Kubernetes to Access Databases</a> was originally published in <a href="https://medium.com/totvsdevelopers">TOTVS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configurando o HashiCorp Boundary no Kubernetes para acessar bancos de dados]]></title>
            <link>https://medium.com/totvsdevelopers/configurando-o-hashicorp-boundary-no-kubernetes-para-acessar-bancos-de-dados-395c18ac210d?source=rss-182b035d247a------2</link>
            <guid isPermaLink="false">https://medium.com/p/395c18ac210d</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[access-control]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Dionathan Chrys]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 01:29:44 GMT</pubDate>
            <atom:updated>2024-02-02T12:49:45.078Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Logo do Boundary" src="https://cdn-images-1.medium.com/max/761/1*WOkxHGLxi1Q_SH1_qZDqqw.png" /><figcaption>HashiCorp Boundary</figcaption></figure><h4>O que é o HashiCorp Boundary?</h4><p>O Boundary da Hashicorp pode prover acesso a diversos sistemas através da identidade de usuário unificada, com apenas um login é possível conceder acesso a diversos sistemas como: instâncias (SSH ou RDP), bancos de dados, cluster Kubernetes e até mesmo requisições HTTP que precisam de autenticação.</p><h4>Qual a vantagem?</h4><p>Imagine um ambiente onde você tem um banco de dados postgres, uma instância linux e um cluster Kubernetes. Sem um gerenciamento de identidade unificado seria necessário criar credenciais para cada um destes sistemas, porém com o Boundary e um login, é possível acessar esses sistemas, criando os perfis e permissões necessárias.</p><h3>Mãos a obra!</h3><p>Eu criei um repositório no GitHub onde fiz uma POC para acessar os bancos de dados, pude testar bem essa funcionalidade do Boundary.</p><p><a href="https://github.com/dionathanchrys/poc-boundary">https://github.com/dionathanchrys/poc-boundary</a></p><p>Vou explicar agora como começar usar ele na sua máquina, <strong>simulando 3 ambientes diferentes. </strong>É isso mesmo que você leu, <strong>não</strong> vamos usar o modo <a href="https://developer.hashicorp.com/boundary/tutorials/oss-getting-started/oss-getting-started-dev"><em>dev</em></a><em>,</em> vamos subir 3 clusters (espero que sua máquina aguente 🤯 )</p><p>Vamos aos requisitos:</p><ul><li>Máquina Linux (Testado no Ubuntu 22.04 mas compatível com outras distribuições)</li><li>kubectl (<a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/">Instalação do kubectl</a>)</li><li>Docker (<a href="https://docs.docker.com/desktop/install/linux-install/">Guia de instalação do Docker</a>)</li><li>Kind (<a href="https://kind.sigs.k8s.io/docs/user/quick-start/#installation">Instalação do Kind</a>)</li><li>HashiCorp Boundary 0.13 (<a href="https://developer.hashicorp.com/boundary/install#Linux">Boundary Installation</a>)</li></ul><p>Após fazer o clone do repositório vamos executar o script em shell que irá criar todos os ambientes.</p><p>Estando na raiz do repositório, execute o script “<em>create-envs.sh</em>” localizado na pasta “app/kind-cluster/base”:</p><pre>app/kind-cluster/base/create-envs.sh</pre><p>Ele irá realizar as seguintes ações:</p><ul><li>Criar uma rede docker para os cluster terem conexões entre eles.</li><li>Criar os cluster através do Kind.</li><li>Aplicas os manifestos Kubernetes, criando os componentes do Boundary (controller, workers e banco de dados), os bancos de dados de teste (simulando uma aplicação chamada <em>foo</em>)</li></ul><p>Após a execução teremos 3 cluster diferentes, simulando ambiente de <strong>serviço</strong>, <strong>desenvolvimento</strong> e <strong>produção</strong>.</p><blockquote>OBS: Entre os apply de deployments e jobs, tem o comando kubectl wait para esperar estar pronto para seguir o script, tem um timeout de 120s, caso seja pouco pode aumentar sem problema nenhum!<br>Use o comando a seguir para apagar tudo e poder rodar o script novamente sem problemas: “docker rm -f svc-cluster-control-plane dev-cluster-control-plane prd-cluster-control-plane &amp;&amp; docker network rm cluster-kind”</blockquote><p>Confirme se os contêineres (clusters) estão em execução usando o comando “docker container ls”, veja abaixo como deve ser a saída:</p><pre>❯ docker container ls<br>CONTAINER ID   IMAGE                  COMMAND                  CREATED          STATUS          PORTS                       NAMES<br>0fb7d586e3bd   kindest/node:v1.25.3   &quot;/usr/local/bin/entr…&quot;   13 minutes ago   Up 12 minutes   127.0.0.1:44133-&gt;6443/tcp   prd-cluster-control-plane<br>dca90dcb21be   kindest/node:v1.25.3   &quot;/usr/local/bin/entr…&quot;   14 minutes ago   Up 13 minutes   127.0.0.1:37027-&gt;6443/tcp   dev-cluster-control-plane<br>133d9eb5909e   kindest/node:v1.25.3   &quot;/usr/local/bin/entr…&quot;   14 minutes ago   Up 14 minutes   127.0.0.1:44399-&gt;6443/tcp   svc-cluster-control-plane</pre><p>Verifique a saída do terminal que ao executar o job de migração do boundary ele informa a senha do admin e salva ela também no repo. Acesse pelo seu navegador o seguinte endereço e use as credenciais recém obtidas.</p><p><a href="http://192.168.222.10:32200/">http://192.168.222.10:32200</a></p><figure><img alt="Tela de login do Boundary" src="https://cdn-images-1.medium.com/max/453/1*oWyUOV-33VFntn7s5hknpA.png" /><figcaption>Tela de Login do Boundary</figcaption></figure><p>Assim que realizar o login, vá até o menu <em>Workers</em>, deverá estar como no print abaixo, mostrando os 2 <em>workers</em> autenticados.</p><figure><img alt="Tela dos Workers" src="https://cdn-images-1.medium.com/max/1007/1*EYvSp5L1DUHHSPJL4pfJlQ.png" /><figcaption>Workers</figcaption></figure><p>Volte no menu <em>Orgs</em> e vamos criar uma nova organização (já existe uma de exemplo para que você possa explorar), clique no botão ‘New Org’ e dê um nome criativo.</p><figure><img alt="Criando nova org" src="https://cdn-images-1.medium.com/max/1023/1*aEqB_zGDSDp9dbK03lLLfw.png" /><figcaption>Criando nova Org</figcaption></figure><p>Agora vamos criar nossos projetos dentro da organização (<em>Org</em>), clique no menu <em>Projects</em> e após <em>New</em>.</p><figure><img alt="Novo projeto" src="https://cdn-images-1.medium.com/max/1013/1*I-V8_rnigu1DuA0wnJIrJg.png" /><figcaption>Criando projetos</figcaption></figure><p>Crie um projeto para cada ambiente para o nosso app imaginário <em>foo</em>, desenvolvimento (dev) e produção (prd).</p><figure><img alt="Projetos criados" src="https://cdn-images-1.medium.com/max/1021/1*KSAqzHyTmPbtLrmF1ub4ew.png" /><figcaption>Novos projetos</figcaption></figure><p>Entre no projeto de dev e vá em <em>Credential Store.</em></p><p>Vamos inserir as credenciais do banco, assim ao conectar no T<em>arget</em> pelo <em>CLI</em> do Boundary ele irá conectar usando essas credenciais. (Não se preocupe veremos tudo isso mais tarde).</p><figure><img alt="Criando Credential Store" src="https://cdn-images-1.medium.com/max/1024/1*u0NoHzoECoUnau47COsaZw.png" /><figcaption>Criando Credential Store</figcaption></figure><p>Crie uma do tipo <em>Static.</em></p><figure><img alt="Static Credential" src="https://cdn-images-1.medium.com/max/1024/1*JSypDwgVKHUsG3ggZ2sqWQ.png" /><figcaption>Static Credential</figcaption></figure><p>Após criar vá em <em>Credentials.</em></p><figure><img alt="Nova credencial" src="https://cdn-images-1.medium.com/max/1024/1*F38dONR5pSDnA7pkojDy0Q.png" /><figcaption>Nova credencial</figcaption></figure><p>Insira um nome, tipo use: <em>Username &amp; Password</em> e as credenciais do banco que se encontram no <em>ConfigMap</em> do <em>Kubernetes</em>.<br>app/foo-postgres/overlay/dev/kustomization.yaml:linha 15</p><figure><img alt="Inserindo credenciais" src="https://cdn-images-1.medium.com/max/1024/1*LI9ECvXHb6Rxx2c8VsKxJw.png" /><figcaption>Inserindo credenciais</figcaption></figure><figure><img alt="Credenciais criadas" src="https://cdn-images-1.medium.com/max/1024/1*IRvuflOWW1kE4PxnGceE_Q.png" /><figcaption>Credenciais criadas</figcaption></figure><p>Vá até o menu <em>Targets</em> e depois em <em>New.</em></p><figure><img alt="Menu targets" src="https://cdn-images-1.medium.com/max/1024/1*DgaooZX6UTeCH9wpp69ZwQ.png" /><figcaption>Targets</figcaption></figure><p>Na adição do <em>target</em> vamos direto ao ponto!</p><ul><li><strong>Target Address</strong>: Mostra como opcional porque você pode configurar os endereços através dos <em>Host Catalogs</em> e <em>Hosts Sets</em>, mas vamos configurar aqui o endereço diretamente no <em>target</em>, neste caso vamos configurar o nome do <em>service</em> do <em>Kubernetes</em> do banco de dados de dev, rode o comando abaixo para verificar:</li></ul><pre>❯ kubectl get services --context kind-dev-cluster -n foo-app<br>NAME               TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)    AGE<br>foo-postgres-svc   ClusterIP   10.96.45.70   &lt;none&gt;        5432/TCP   25 minutes</pre><p>O nome do <em>service</em> é “<strong>foo-postgres-svc”</strong>, porém como vamos acessar de um <em>namespace</em> para outro dentro do mesmo <em>cluster</em>, precisamos passar o endereço completo do <em>service</em>, que é composto do nome do “<em>service.namespace.svc.cluster.local”. </em>O nosso ficará assim: <strong>foo-postgres-svc.foo-app.svc.cluster.local</strong></p><ul><li><strong>Default Port:</strong> Porta de acesso ao nosso banco de dados, nosso caso é a 5432, padrão do postgres.</li></ul><figure><img alt="Criando target" src="https://cdn-images-1.medium.com/max/1024/1*_7Ved7R3kTcXCo1W0SkgSw.png" /><figcaption>Criando target</figcaption></figure><p>Mais abaixo temos a configuração de <em>Workers</em>, neste caso como temos “múltiplos ambientes” precisamos configurar e dizer ao <em>Controller</em> qual <em>Worker</em> deve ser usado para realizar a conexão com o <em>Target</em>, isso é feito através da tag.</p><blockquote>O desenho da nossa estrutura é como essa abaixo, ela foi se baseada <a href="https://developer.hashicorp.com/boundary/docs/install-boundary/system-requirements#network-connectivity">nesta</a> página da documentação do Boundary</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*e26aMR93bdH_GpnQXMAHmA.png" /><figcaption>Exemplo acessando um target no ambiente de DEV</figcaption></figure><p>… voltando a configuração de <em>Worker</em> dentro do <em>Target</em> precisamos colocar a <em>tag</em> do <em>Worker</em>, as tags foram configuradas na linha 17 do arquivo de DEV:</p><ul><li><em>“</em>app/boundary-worker/overlay/dev/config/pki-worker.hcl<em>” </em>em DEV</li></ul><pre>  tags {<br>    env  = [&quot;dev&quot;]<br>    type = [&quot;egress&quot;]<br>  }</pre><p><a href="https://developer.hashicorp.com/boundary/docs/concepts/filtering/worker-tags">Aqui na documentação</a> você pode conferir mais detalhes sobre as <em>tags</em> dos <em>workers.<br></em>No filtro use conforme o print abaixo:</p><pre>&quot;dev&quot; in &quot;/tags/env&quot;</pre><figure><img alt="tag do worker" src="https://cdn-images-1.medium.com/max/687/1*JdtYzqP4nueT8_GuUKoilQ.png" /><figcaption>Tag do worker</figcaption></figure><p>Depois de criar o <em>target</em> entre nele novamente e vá em <em>brokered credentials.</em></p><figure><img alt="Adicionando Brokered Credentials" src="https://cdn-images-1.medium.com/max/1024/1*Y-_QbZIyK1kgz1IBSzkIlQ.png" /><figcaption>Adicionando Brokered Credentials</figcaption></figure><p>Faça a associação.</p><figure><img alt="Associando Brokered Credentials" src="https://cdn-images-1.medium.com/max/1024/1*DU7xzsBj4BMJk14j5PvRvQ.png" /><figcaption>Associando Brokered Credentials</figcaption></figure><figure><img alt="Brokered Credentials Associado" src="https://cdn-images-1.medium.com/max/1024/1*A_sF9bGLKuVCrDhi5dJBBQ.png" /><figcaption>Brokered Credentials Associado</figcaption></figure><p>Agora você repetir o processo para o ambiente de PRD, criando as credenciais, o <em>target</em> e associando.</p><h3>Vamos ver funcionando!</h3><p>Agora que está tudo configurado e ok, vamos acessar.<br>Iremos usar o <em>client CLI </em>do Boundary, poderíamos fazer pelo app com interface, porém não conseguimos usar o <em>Brokered Credentials</em> e perderia o sentido deste artigo. É claro que poderíamos integrar com um <em>Vault</em> e melhorar ainda mais o gerenciamento das senhas, mas isso ficará para um outro momento.</p><p>Vamos ao terminal…</p><pre>boundary authenticate password \<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-auth-method-id ampw_eSdigWzNW1 \<br>-scope-id o_KV9tApRJlT</pre><p>Use as mesmas credenciais que foram utilizadas para fazer login na interface web.</p><p>Para entender bem os parâmetros você pode rodar o seguinte comando “boundary authenticate --help” ou pode consultar a documentação.</p><p>Os <em>ids</em> vão mudar em cada instalação, para consulta-los segue os links:</p><ul><li><strong>auth-method-id:</strong> <a href="http://192.168.222.10:32200/scopes/global/auth-methods">http://192.168.222.10:32200/scopes/global/auth-methods</a></li><li><strong>scope-id:</strong> <a href="http://192.168.222.10:32200/scopes/global/scopes">http://192.168.222.10:32200/scopes/global/scopes</a></li></ul><p>Todos esses parâmetros podem ser configurados com variáveis de ambiente, o que agilizaria o processo de login(sugiro que faça isso), para consultar o nome das variáveis, use os seguintes comandos:</p><ul><li>boundary authenticate --help</li><li>boundary authenticate password --help</li></ul><p>Caso tenha logado com sucesso, terá a seguinte saída:</p><pre>❯boundary authenticate password \<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-scope-id o_KV9tApRJlT \<br>-auth-method-id ampw_eSdigWzNW1<br>Please enter the login name (it will be hidden): <br>Please enter the password (it will be hidden): <br><br>Authentication information:<br>  Account ID:      acctpw_nIvOD6rkRR<br>  Auth Method ID:  ampw_eSdigWzNW1<br>  Expiration Time: Tue, 16 Jan 2024 21:46:54 -03<br>  User ID:         u_d0hKJ0jcXH<br><br>The token was successfully stored in the chosen keyring and is not displayed here.</pre><p>Agora podemos nos conectar no <em>target</em>, vamos ao comando:</p><pre>boundary connect postgres \<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-target-id ttcp_lwgSUO7dSG \<br>-dbname postgres</pre><p>Se quiser saber mais… “boundary connect --help”</p><p>Dando tudo certo teremos a seguinte saída:</p><pre>❯ boundary connect postgres \                                                                                       ⏎ 23:19:30 - 2024-01-09<br>-addr http://192.168.222.10:32200 \<br>-keyring-type secret-service \<br>-target-id ttcp_lwgSUO7dSG \<br>-dbname postgres<br>psql (14.10 (Ubuntu 14.10-0ubuntu0.22.04.1), server 13.13 (Debian 13.13-1.pgdg120+1))<br>Type &quot;help&quot; for help.<br><br>postgres=#</pre><p>Isso que significa que você está dentro do banco de dados, <strong>sem informar as credenciais no momento do login</strong>, pois ele usou aquelas que associamos anteriormente. Em um cenário real a pessoa que fará acesso ao banco não terá contato com as credenciais, você deverá configurar <em>Roles e Grupos</em> para que ela tenha acesso somente aos <em>targets</em>.</p><h4>Conclusão</h4><p>Apresentamos uma POC, onde podemos simular de forma simples alguns ambientes, mas em um cenário real onde teremos OIDC para logar e Vault para guardar as senhas fica bem mais interessante.</p><p>Pretendo no futuro ainda implementar mais algumas coisas nessa POC, listei elas nas issues do repositório, mas caso você tenha alguma sugestão ou encontre algum problema, não deixe de abrir uma issue no <a href="https://github.com/dionathanchrys/poc-boundary/issues">GitHub</a>.</p><p>Espero ter te ajudado de alguma forma, qualquer dúvida deixe um comentário.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=395c18ac210d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/totvsdevelopers/configurando-o-hashicorp-boundary-no-kubernetes-para-acessar-bancos-de-dados-395c18ac210d">Configurando o HashiCorp Boundary no Kubernetes para acessar bancos de dados</a> was originally published in <a href="https://medium.com/totvsdevelopers">TOTVS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comandos úteis e mais usados no Kubernetes]]></title>
            <link>https://medium.com/totvsdevelopers/comandos-uteis-e-mais-usados-no-kubernetes-cc764f1a9450?source=rss-182b035d247a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc764f1a9450</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[container-orchestration]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Dionathan Chrys]]></dc:creator>
            <pubDate>Mon, 31 Jul 2023 23:58:53 GMT</pubDate>
            <atom:updated>2023-08-01T14:30:54.434Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gg6X0u7nUK1gBIl1rHO8Ew.jpeg" /></figure><p>Sabemos que o Kubernetes é uma ferramenta muito utilizada para rodar aplicações em diversas escalas, com esse uso tão comum é essencial que saibamos lidar com ele, então vou listar alguns comandos que considero importante para uso durante o desenvolvimento de aplicações, testes e afins.</p><blockquote>Para que seus comandos funcionem de forma correta, você precisa já ter configurado o contexto e namespace do seu cluster no seu terminal. Levando em consideração que você já tenha o seu arquivo kubeConfig, para configurar ou trocar de contexto/namespace, você pode usar o seguinte comando:</blockquote><pre>kubectl config set-context &lt;SEU-CONTEXTO&gt; --namespace &lt;SEU-NAMESPACE&gt;</pre><h4>Pods</h4><p>O pod é a menor unidade do Kubernetes, é dentro dele que temos os contêineres, segue abaixo alguns comandos:</p><pre># Listar os pods<br>kubectl get pods<br><br># Listagem com mais detalhes<br>kubectl get pods -o wide<br><br># Criar um YAML do pod descrito<br>kubectl get pod &lt;NOME-POD&gt; -o yaml &gt; pod.yaml<br><br># Informações detalhadas de um determinado pod<br>kubectl describe &lt;NOME-POD&gt;<br><br># Executar um comando dentro do container do pod<br>kubectl exec -it &lt;NOME-POD&gt; -c &lt;NOME-CONTAINER&gt; -- &lt;COMANDO&gt;<br>## O nome do container pode ser suprimido caso só exista um dentro do pod<br>### Exemplo:<br>kubectl exec -it nginx -- sh<br><br>#Copiar conteúdo para dentro do Pod ou para o seu computador<br>kubectl cp &lt;SOURCE&gt; &lt;DESTINATION&gt;<br>kubectl cp ~/meu/caminho/local &lt;NOME-POD&gt;:/src/app -c &lt;NOME-CONTAINER&gt; --v=4</pre><h4>Deployments</h4><p>O deployment é o que controla o Replica Set que por sua vez controla os pods, vamos ver alguns comandos:</p><pre># Lista os deployments<br>kubectl get deployments<br><br># Lista os deployments com mais detalhes<br>kubectl get deployments -o wide<br><br># Criar um YAML do deployments descrito<br>kubectl get deployment &lt;NOME-DEPLOY&gt; -o yaml &gt; deploy.yaml<br><br># Informações detalhadas de um determinado deployment<br>kubectl describe &lt;NOME-DEPLOY&gt;<br><br># Durante uma atualização use esse comando para acompanhar o andamento<br>kubectl rollout status deployment &lt;NOME-DEPLOY&gt;<br><br># Pausar deployment, útil quando você tem pipelines que controlam o processo e não quer que seja atualizado por alguma motivo<br>kubectl rollout pause deployment &lt;NOME-DEPLOY&gt;<br><br># Remover do pause<br>kubectl rollout resume deployment &lt;NOME-DEPLOY&gt;</pre><h4>Services</h4><p>O Service nada mais é uma forma de você expor a sua aplicação, existem 3 tipos de services:</p><ul><li>ClusterIP: Cria um serviço (IP) que só funciona dentro do cluster</li><li>NodePort: Expõe uma porta dos seus nodes para expor o serviço</li><li>LoadBalancer: Cria um LoadBalancer</li></ul><p>Alguns comandos:</p><pre># Lista os services<br>kubectl get services<br><br># Lista os services com mais detalhes<br>kubectl get services -o wide<br><br># Criar um YAML do services descrito<br>kubectl get services &lt;NOME-SERVICE&gt; -o yaml &gt; deploy.yaml<br><br># Informações detalhadas de um determinado service<br>kubectl describe &lt;NOME-SERVICE&gt;<br><br># Cria um service<br>kubectl expose &lt;RECURSO&gt; &lt;NOME-RECURSO&gt; --port &lt;PORTA&gt; --type=&lt;TIPO&gt;<br>## Exemplo<br>kubectl expose deployment nginx --port 80 --type=NodePort</pre><p>Avulsos</p><pre># Simular um comando<br>kubectl &lt;COMANDO&gt; --dry-run=client<br># Simular o comando e ter uma saída em YAML<br>kubectl &lt;COMANDO&gt; --dry-run=client -o yaml &gt; spec.yaml<br><br># Aplicar um arquivo com um ou mais manifestos<br>kubectl apply -f caminho/do/arquivo.yaml<br># Aplicar um arquivo de kustomize<br>kubectl apply -k caminho/da/pasta<br><br># Mostras as versões de API disponíveis no cluster<br>kubectl api-versions<br><br># Realizar um port-forward<br>kubectl port-forward &lt;RECURSO&gt;/&lt;NOME-RECURSO&gt;<br>## Exemplos:<br>kubectl port-forward services/nginx-svc 8000:80<br>kubectl port-forward pods/nginx 8000:80<br>kubectl port-forward deployments/nginx 8000:80<br><br># Lista os contextos<br>kubectl config get-contexts</pre><p>Para facilitar sua vida, caso você não goste do terminal, existe uma “IDE” para o Kubernetes, o nome dela é OpenLens.</p><p>O link do projeto no GitHub está <a href="https://github.com/MuhammedKalkan/OpenLens">aqui</a>.</p><p><a href="https://github.com/MuhammedKalkan/OpenLens/releases">Instalação para Windows, Linux e Mac</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc764f1a9450" width="1" height="1" alt=""><hr><p><a href="https://medium.com/totvsdevelopers/comandos-uteis-e-mais-usados-no-kubernetes-cc764f1a9450">Comandos úteis e mais usados no Kubernetes</a> was originally published in <a href="https://medium.com/totvsdevelopers">TOTVS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up databases access with CloudBeaver on Kubernetes]]></title>
            <link>https://medium.com/totvsdevelopers/setting-up-databases-access-with-cloudbeaver-on-kubernetes-7a811c04f24c?source=rss-182b035d247a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a811c04f24c</guid>
            <category><![CDATA[dbeaver]]></category>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Dionathan Chrys]]></dc:creator>
            <pubDate>Wed, 25 Jan 2023 02:47:18 GMT</pubDate>
            <atom:updated>2023-02-01T02:26:07.829Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*bZ1FzEl6hLFx2gt3mv_phQ.png" /><figcaption>CloudBeaver</figcaption></figure><p><a href="https://medium.com/@dionathan.chrys/configurando-acesso-a-banco-de-dados-com-o-cloudbeaver-no-kubernetes-12b62e4a3d30">PT-BR Version</a></p><p>Hello everyone! This article is to show and teach you how to set up automatic and authenticated access to your databases through CloudBeaver.</p><p>In case you have fallen into this article, I will explain what it is for. CloudBeaver is a database management tool that you can access and use through your browser, on the exposed port 8978 of the container, but why use it? We have several other options such as PGadmin, MySQL Workbench, HeidiSQL, Beekeeper Studio among many others. Well, I will list some very interesting advantages of it.</p><ul><li>Supports multiple databases.</li><li>Allows you to manipulate data like a spreadsheet.</li><li>Database navigation structure.</li><li>Data export and migration in various formats.</li><li>SSH tunnels for remote database connectivity.</li><li>SQL editor with intelligent auto-completion and syntax highlighting.</li><li>Great user interface.</li><li>User/role based security model.</li></ul><p>This and other features are available in the <em>community</em> (free) version, there are also <em>Enterprise</em> and <em>AWS</em> versions. You can check for more details <a href="https://github.com/dbeaver/cloudbeaver/wiki#product-versions">here</a>.</p><p>Alright! Given the proper introduction, let’s go!</p><p>Here is the repository with the CloudBeaver configs and the Kubernetes specs.</p><p><a href="https://github.com/dionathanchrys/cloud-beaver">https://github.com/dionathanchrys/cloud-beaver</a></p><p>In the <em>kustomization.yaml</em> file we have the definition of the <em>ConfigMaps</em> that will be files from the repository, these <em>ConfigMaps</em> in turn will be used to create the volumes in the deployment.yaml and these volumes will be mounted on our pod, replacing the default files and configuring the application.</p><p>Hold on! I will explain better below.</p><p>In the <em>configMapGenerator</em>, we create the <em>ConfigMaps</em> pointing to the <em>.json</em> or <em>.config</em> files with the CloudBeaver configurations. (I will talk about these files later)</p><p><em>kustomization.yaml:</em></p><pre>configMapGenerator:<br>  - name: configmap-name<br>    files:<br>      - path/to/your/file.json</pre><p>Real example:</p><pre>configMapGenerator:<br>  - name: dbeaver-product-configmap<br>    files:<br>      - dbeaver/configs/product.conf<br>  - name: dbeaver-sources-user-configmap<br>    files:<br>      - dbeaver/configs/user/data-sources.json<br>  - name: dbeaver-sources-global-configmap<br>    files:<br>      - dbeaver/configs/global/data-sources.json<br>  - name: dbeaver-server-configmap<br>    files:<br>      - dbeaver/configs/cloudbeaver.conf</pre><p>After applied</p><pre>❯ kubectl get configmaps<br><br>NAME                                          DATA   AGE<br>dbeaver-product-configmap-kg79td7884          1      3d15h<br>dbeaver-server-configmap-m5fc6m9ff7           1      3d15h<br>dbeaver-sources-global-configmap-9b82g2h9bm   1      3d15h<br>dbeaver-sources-user-configmap-5d7fttct9h     1      3d15h</pre><p>To use these <em>configMaps</em>, we must create the volumes with them in the deployment, see below:</p><p><em>deployment.yaml:</em></p><pre>volumes:<br>  - name: volume-name<br>    configMap:<br>      name: configmap-name</pre><p>Real example:</p><pre>volumes:<br>  - name: dbeaver-product<br>    configMap:<br>      name: dbeaver-product-configmap<br>  - name: dbeaver-sources-user<br>    configMap:<br>      name: dbeaver-sources-user-configmap<br>  - name: dbeaver-sources-global<br>    configMap:<br>      name: dbeaver-sources-global-configmap<br>  - name: dbeaver-server<br>    configMap:<br>      name: dbeaver-server-configmap</pre><p>With the volumes declared, we can now mount them:</p><pre>volumeMounts:<br>  - name: volume-name<br>    mountPath: /path/inside/container/to/your/file.conf<br>    subPath: file.conf</pre><p>Real example:</p><pre>volumeMounts:<br>  - name: dbeaver-product<br>    mountPath: /opt/cloudbeaver/conf/product.conf<br>    subPath: product.conf<br>  - name: dbeaver-sources-user<br>    mountPath: /opt/cloudbeaver/workspace/user-projects/admin.dbeaver/.dbeaver/data-sources.json<br>    subPath: data-sources.json<br>  - name: dbeaver-sources-global<br>    mountPath: /opt/cloudbeaver/workspace/GlobalConfiguration/.dbeaver/data-sources.json<br>    subPath: data-sources.json<br>  - name: dbeaver-server<br>    mountPath: /opt/cloudbeaver/conf/cloudbeaver.conf<br>    subPath: cloudbeaver.conf</pre><p>Finally, the <em>deployment.yaml</em> (cloudbeaver) file should look like this:</p><pre>kind: Deployment<br>apiVersion: apps/v1<br>metadata:<br>  name: dbeaver<br>  namespace: cloud-beaver-test<br>spec:<br>  progressDeadlineSeconds: 600<br>  replicas: 1<br>  revisionHistoryLimit: 1<br>  strategy:<br>    rollingUpdate:<br>      maxSurge: 1<br>      maxUnavailable: 0<br>    type: RollingUpdate<br>  selector:<br>    matchLabels:<br>      app: dbeaver-app<br>  template:<br>    metadata:<br>      labels:<br>        app: dbeaver-app<br>    spec:<br>      containers:<br>        - name: dbeaver<br>          image: dbeaver/cloudbeaver:latest<br>          imagePullPolicy: Always<br>          resources:<br>            requests:<br>              cpu: 200m<br>              memory: 256Mi<br>            limits:<br>              cpu: 500m<br>              memory: 256Mi<br>          ports:<br>            - name: web-access<br>              containerPort: 8978<br>          livenessProbe:<br>            httpGet:<br>              path: /<br>              port: 8978<br>              scheme: HTTP<br>            initialDelaySeconds: 300<br>            timeoutSeconds: 10<br>            periodSeconds: 300<br>            successThreshold: 1<br>            failureThreshold: 5<br>          envFrom:<br>          - secretRef:<br>              name: dbeaver-secret<br>          volumeMounts:<br>            - name: dbeaver-product<br>              mountPath: /opt/cloudbeaver/conf/product.conf<br>              subPath: product.conf<br>            - name: dbeaver-sources-user<br>              mountPath: /opt/cloudbeaver/workspace/user-projects/admin.dbeaver/.dbeaver/data-sources.json<br>              subPath: data-sources.json<br>            - name: dbeaver-sources-global<br>              mountPath: /opt/cloudbeaver/workspace/GlobalConfiguration/.dbeaver/data-sources.json<br>              subPath: data-sources.json<br>            - name: dbeaver-server<br>              mountPath: /opt/cloudbeaver/conf/cloudbeaver.conf<br>              subPath: cloudbeaver.conf<br>      volumes:<br>        - name: dbeaver-product<br>          configMap:<br>            name: dbeaver-product-configmap<br>        - name: dbeaver-sources-user<br>          configMap:<br>            name: dbeaver-sources-user-configmap<br>        - name: dbeaver-sources-global<br>          configMap:<br>            name: dbeaver-sources-global-configmap<br>        - name: dbeaver-server<br>          configMap:<br>            name: dbeaver-server-configmap</pre><p>And the <em>kustomization.yaml</em> (cloudbeaver part of) like this:</p><pre>apiVersion: kustomize.config.k8s.io/v1beta1<br>kind: Kustomization<br><br>namespace: cloud-beaver-test<br><br>resources:<br>  - namespace.yaml<br>  - dbeaver/deployment.yaml<br>  - dbeaver/service.yaml<br>  - postgres/deployment.yaml<br>  - postgres/service.yaml<br>  - mysql/deployment.yaml<br>  - mysql/service.yaml<br><br>configMapGenerator:<br>#DBEAVER<br>  - name: dbeaver-product-configmap<br>    files:<br>      - dbeaver/configs/product.conf<br>  - name: dbeaver-sources-user-configmap<br>    files:<br>      - dbeaver/configs/user/data-sources.json<br>  - name: dbeaver-sources-global-configmap<br>    files:<br>      - dbeaver/configs/global/data-sources.json<br>  - name: dbeaver-server-configmap<br>    files:<br>      - dbeaver/configs/cloudbeaver.conf<br>#POSTGRES<br>  - name: postgres-configmap<br>    literals:<br>    - POSTGRES_USER=my-db-user<br>    - POSTGRES_PASSWORD=Password123<br>    - POSTGRES_DB=my-postgre-db<br>#MYSQL<br>  - name: mysql-configmap<br>    literals:<br>    - MYSQL_ROOT_PASSWORD=PasswordROOT<br>    - MYSQL_USER=my-db-user<br>    - MYSQL_PASSWORD=Password123<br>    - MYSQL_DATABASE=my-mysql-db<br><br>secretGenerator:<br>#DBEAVER<br>- name: dbeaver-secret<br>  literals:<br>    - CB_SERVER_NAME=CloudBeaver Test Server<br>    - CB_ADMIN_NAME=admin.dbeaver<br>    - CB_ADMIN_PASSWORD=Password123<br><br>commonLabels:<br>  kubernetes.io/environment: dev</pre><p>Note: these secrets generated in the kustomization.yaml are CloudBeaver environment variables:</p><pre>CB_SERVER_NAME=Server name<br>CB_ADMIN_NAME=&lt;admin user&gt;<br>CB_ADMIN_PASSWORD=&lt;yourpasswordhere&gt;</pre><p>Now that we know how to configure, let’s understand what these 3 files are for: <em>data-sources.json, cloudbeaver.conf, product.conf</em></p><h3>data-sources.json</h3><p>In this file is where we make the connection settings for the database instances, in the example we will use connections for a Postgres and another MySql database.</p><p>It’s located in the following path:</p><p><strong><em>/opt/cloudbeaver/workspace/user-projects/&lt;USER&gt;/.dbeaver/data-sources.json</em></strong></p><p>This settings only work for the logged user, the connections will only be available after logging in to CloudBeaver.</p><p><strong><em>/opt/cloudbeaver/workspace/GlobalConfiguration/.dbeaver/data-sources.json</em></strong></p><p>As the name of the folder already says, they are global configurations, all settings made here will be available without authentication in CloudBeaver, if you enable anonymous access.</p><p>I will explain the main parameters of this JSON so you can configure without problems:</p><p>“<strong>folders</strong>”: If you want to configure multiple connections, you can separate them into folders.</p><p>“<strong>save-password</strong>”: It’s better not to save the access password to your database right? (leave it false)</p><p>“<strong>folder</strong>”: If you have created a folder, declare it here.</p><p>“<strong>user</strong>”: Database user, if you declare it here, it will auto-complete for you on the login screen.</p><p>“<strong>host</strong>”: IP or DNS address of your database instance.</p><p>“<strong>port</strong>”: Instance database access port.</p><p>“<strong>database</strong>”: Database that the communication will be made with.</p><p>“<strong>url</strong>”: The url is composed of the following parameters &lt;provider&gt;://&lt;host&gt;:&lt;port&gt;/&lt;database&gt;</p><pre>{<br> &quot;folders&quot;: {<br>  &quot;My DBs&quot;: {}<br> },<br> &quot;connections&quot;: {<br>  &quot;DB-example-01&quot;: {<br>   &quot;provider&quot;: &quot;postgresql&quot;,<br>   &quot;driver&quot;: &quot;postgres-jdbc&quot;,<br>   &quot;name&quot;: &quot;DB-example-01&quot;,<br>   &quot;description&quot;: &quot;Postgre connection&quot;,<br>   &quot;save-password&quot;: false,<br>   &quot;show-system-objects&quot;: true,<br>   &quot;read-only&quot;: false,<br>   &quot;folder&quot;: &quot;My DBs&quot;,<br>   &quot;configuration&quot;: {<br>    &quot;user&quot;: &quot;my-db-user&quot;,<br>    &quot;host&quot;: &quot;postgres&quot;,<br>    &quot;port&quot;: &quot;5432&quot;,<br>    &quot;database&quot;: &quot;my-postgre-db&quot;,<br>    &quot;url&quot;: &quot;jdbc:postgresql://postgres:5432/my-postgre-db&quot;,<br>    &quot;type&quot;: &quot;dev&quot;,<br>    &quot;provider-properties&quot;: {<br>     &quot;@dbeaver-show-non-default-db@&quot;: &quot;true&quot;<br>    },<br>    &quot;auth-model&quot;: &quot;native&quot;<br>   }<br>  },<br>  &quot;DB-example-02&quot;: {<br>   &quot;provider&quot;: &quot;mysql&quot;,<br>   &quot;driver&quot;: &quot;mysql8&quot;,<br>   &quot;name&quot;: &quot;DB-example-02&quot;,<br>   &quot;description&quot;: &quot;&quot;,<br>   &quot;save-password&quot;: false,<br>   &quot;show-system-objects&quot;: true,<br>   &quot;read-only&quot;: false,<br>   &quot;folder&quot;: &quot;My DBs&quot;,<br>   &quot;configuration&quot;: {<br>    &quot;user&quot;: &quot;my-db-user&quot;,<br>    &quot;host&quot;: &quot;mysql&quot;,<br>    &quot;port&quot;: &quot;3306&quot;,<br>    &quot;database&quot;: &quot;my-mysql-db&quot;,<br>    &quot;url&quot;: &quot;jdbc:mysql://mysql:3306/my-mysql-db&quot;,<br>    &quot;type&quot;: &quot;dev&quot;,<br>    &quot;properties&quot;: {<br>     &quot;allowPublicKeyRetrieval&quot;: &quot;true&quot;<br>    },<br>    &quot;provider-properties&quot;: {<br>     &quot;@dbeaver-show-non-default-db@&quot;: &quot;false&quot;<br>    },<br>    &quot;auth-model&quot;: &quot;native&quot;<br>   }<br>  }<br> },<br> &quot;connection-types&quot;: {<br>  &quot;dev&quot;: {<br>   &quot;name&quot;: &quot;Development&quot;,<br>   &quot;color&quot;: &quot;0,0,255&quot;,<br>   &quot;description&quot;: &quot;Regular development database&quot;,<br>   &quot;auto-commit&quot;: true,<br>   &quot;confirm-execute&quot;: false,<br>   &quot;confirm-data-change&quot;: false,<br>   &quot;auto-close-transactions&quot;: false<br>  }<br> }<br>}</pre><h3>cloudbeaver.conf</h3><p><em>/opt/cloudbeaver/conf/product.conf</em></p><p>Here we have several general settings for the CloudBeaver instance.</p><p>I will highlight the ones I think are important:</p><p>“<strong>anonymousAccessEnabled</strong>”: Here we define if will be anonymous access or not. (Leave it false)</p><p>“<strong>publicCredentialsSaveEnabled</strong>”: Leave it false, I don’t need to say why. Right?</p><p>“<strong>adminCredentialsSaveEnabled</strong>”: Leave it false, I don’t need to say why. Right?</p><pre>{<br>    server: {<br>        serverPort: 8978,<br><br>        workspaceLocation: &quot;workspace&quot;,<br>        contentRoot: &quot;web&quot;,<br>        driversLocation: &quot;drivers&quot;,<br><br>        rootURI: &quot;/&quot;,<br>        serviceURI: &quot;/api/&quot;,<br><br>        productConfiguration: &quot;conf/product.conf&quot;,<br><br>        expireSessionAfterPeriod: 1800000,<br><br>        develMode: false,<br><br>        enableSecurityManager: false,<br><br>        database: {<br>            driver=&quot;h2_embedded&quot;,<br>            url: &quot;jdbc:h2:${workspace}/.data/cb.h2.dat&quot;,<br><br>            createDatabase: true,<br><br>            initialDataConfiguration: &quot;conf/initial-data.conf&quot;,<br><br>            pool: {<br>                minIdleConnections: 4,<br>                maxIdleConnections: 10,<br>                maxConnections: 100,<br>                validationQuery: &quot;SELECT 1&quot;<br>            }<br>        }<br><br>    },<br>    app: {<br>        anonymousAccessEnabled: false,<br>        anonymousUserRole: &quot;user&quot;,<br>        supportsCustomConnections: false,<br><br>        forwardProxy: false,<br><br>        publicCredentialsSaveEnabled: false,<br>        adminCredentialsSaveEnabled: false,<br><br>        resourceManagerEnabled: true,<br><br>        resourceQuotas: {<br>            dataExportFileSizeLimit: 10000000,<br>            resourceManagerFileSizeLimit: 500000,<br>            sqlMaxRunningQueries: 100,<br>            sqlResultSetRowsLimit: 100000,<br>            sqlResultSetMemoryLimit: 2000000,<br>            sqlTextPreviewMaxLength: 4096,<br>            sqlBinaryPreviewMaxLength: 261120<br>        },<br>        enabledAuthProviders: [<br>            &quot;local&quot;<br>        ],<br><br>        disabledDrivers: [<br>            &quot;sqlite:sqlite_jdbc&quot;,<br>            &quot;h2:h2_embedded&quot;,<br>            &quot;clickhouse:yandex_clickhouse&quot;<br>        ]<br><br>    }<br><br>}</pre><h3>product.conf</h3><p><em>/opt/cloudbeaver/conf/product.conf</em></p><p>You can find some customization settings here, I made changes only in the ones below:</p><p>“<strong>defaultTheme</strong>”: Theme definition, I sugest “dark”.</p><p>“<strong>defaultLanguage</strong>”: “en”</p><pre>// Product configuration. Customized web application behavior<br>// It is in JSONC format<br>{<br>    // Global properties<br>    core: {<br>        // User defaults<br>        user: {<br>            defaultTheme: &quot;dark&quot;,<br>            defaultLanguage: &quot;en&quot;<br>        },<br>        app: {<br>            // Log viewer config<br>            logViewer: {<br>                refreshTimeout: 3000,<br>                logBatchSize: 1000,<br>                maxLogRecords: 2000,<br>                maxFailedRequests: 3<br>            }<br>        },<br>        authentication: {<br>            anonymousAccessEnabled: false<br>        }<br>    },<br>    // Notifications config<br>    core_events: {<br>        notificationsPool: 5<br>    },<br>    plugin_data_spreadsheet_new: {<br>        hidden: false<br>    },<br>    plugin_data_export: {<br>        disabled: false<br>    }<br>}</pre><h3>Let’s get to work!</h3><p>Now that we have this information, let’s put it into practice using some database pods.</p><p>Clone the repository, go to the folder and execute the command bellow</p><pre>❯ kubectl apply -k .</pre><p>This command will read the <em>kustomization.yaml</em> file and apply all the specs, configurations, variables, and <em>configMaps</em> that are declared in it.</p><p>Commando output:</p><pre>❯ kubectl apply -k k8s<br>namespace/cloud-beaver-test created<br>configmap/dbeaver-product-configmap-kg79td7884 created<br>configmap/dbeaver-server-configmap-m5fc6m9ff7 created<br>configmap/dbeaver-sources-global-configmap-9b82g2h9bm created<br>configmap/dbeaver-sources-user-configmap-5kf2gtc878 created<br>configmap/mysql-configmap-62g74m555t created<br>configmap/postgres-configmap-5kt6k78dkc created<br>secret/dbeaver-secret-b8bmc6h476 created<br>service/dbeaver created<br>service/mysql created<br>service/postgres created<br>deployment.apps/dbeaver created<br>deployment.apps/mysql created<br>deployment.apps/postgres created</pre><p>Check if everything has been deployed correctly and do a port-forward on the CloudBeaver pod to test it:</p><pre>❯ kubectl port-forward -n cloud-beaver-test pods/dbeaver-7958f5b776-rk9qh 9090:8978</pre><p>Log in to CloudBeaver and it should look like this if everything is correct, especially with the <em>data-sources.json</em> file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/0*AX3XPbOah727UPy-.png" /><figcaption>CloudBeaver Connections</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a811c04f24c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/totvsdevelopers/setting-up-databases-access-with-cloudbeaver-on-kubernetes-7a811c04f24c">Setting up databases access with CloudBeaver on Kubernetes</a> was originally published in <a href="https://medium.com/totvsdevelopers">TOTVS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configurando acesso a banco de dados com o CloudBeaver no Kubernetes]]></title>
            <link>https://medium.com/totvsdevelopers/configurando-acesso-a-banco-de-dados-com-o-cloudbeaver-no-kubernetes-12b62e4a3d30?source=rss-182b035d247a------2</link>
            <guid isPermaLink="false">https://medium.com/p/12b62e4a3d30</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[dbeaver]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Dionathan Chrys]]></dc:creator>
            <pubDate>Tue, 24 Jan 2023 02:01:10 GMT</pubDate>
            <atom:updated>2023-02-06T16:58:28.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*bZ1FzEl6hLFx2gt3mv_phQ.png" /><figcaption>CloudBeaver</figcaption></figure><p><a href="https://medium.com/@dionathan.chrys/setting-up-databases-access-with-cloudbeaver-on-kubernetes-7a811c04f24c">Versão em Inglês</a></p><p>Olá pessoal! A intenção principal deste artigo é mostrar e ensinar para vocês como configurar de forma <strong>automática e com autenticação</strong> o acesso aos seus bancos de dados pelo CloudBeaver.</p><p>Caso você tenha caído de paraquedas neste artigo, vou te explicar para o que ele serve. O CloudBeaver é uma ferramenta de gerenciamento de banco de dados que você pode acessar e usar pelo seu navegador, através da porta 8978 exposta do contêiner, mas porquê utilizá-lo? Temos diversas outras opções como PGadmin, MySQL Workbench, HeidiSQL, Beekeeper Studio entre muitos outros. Pois bem, vou te listar algumas vantagens bem interessantes dele.</p><ul><li>Suporta diversos bancos de dados.</li><li>Permite manipular os dados como se fossem uma planilha.</li><li>Estrutura de navegação de banco de dados.</li><li>Exportação e migração de dados em vários formatos.</li><li>Túneis SSH para conectividade de bancos de dados remotos.</li><li>Editor SQL com preenchimento automático inteligente e realce de sintaxe.</li><li>Ótima interface.</li><li>Modelo de segurança baseado em usuário/função.</li></ul><p>Isso e outros recursos estão na versão <em>community</em> (free), ainda existe as versões <em>Enterprise </em>e<em> AWS.</em> Pode verificar com mais detalhes <a href="https://github.com/dbeaver/cloudbeaver/wiki#product-versions">aqui</a>.</p><p>OK! Dada a devida introdução, vamos lá!</p><p>Aqui está o repositório com as config do CloudBeaver e as specs do kubernetes.</p><p><a href="https://github.com/dionathanchrys/cloud-beaver">https://github.com/dionathanchrys/cloud-beaver</a></p><p>No arquivo <em>kustomization.yaml </em>temos a definição dos <em>ConfigMaps</em> que serão arquivos do repositório, estes <em>ConfigMaps</em> por sua vez serão usados para criar os volumes no <em>deployment.yaml</em> e esses volumes serão montados no nosso pod, substituindo os arquivos padrões e configurando a aplicação.</p><p>Calma! Vou explicar melhor logo abaixo.</p><p>No <em>configMapGenerator</em> criamos os <em>ConfigMaps</em> apontando para os arquivos <em>.json</em> ou <em>.config </em>com as configurações do CloudBeaver. (Falarei destes arquivos mais a frente)</p><p><em>kustomization.yaml:</em></p><pre>configMapGenerator:<br>  - name: configmap-name<br>    files:<br>      - path/to/your/file.json</pre><p>Exemplo na prática:</p><pre>configMapGenerator:<br>  - name: dbeaver-product-configmap<br>    files:<br>      - dbeaver/configs/product.conf<br>  - name: dbeaver-sources-user-configmap<br>    files:<br>      - dbeaver/configs/user/data-sources.json<br>  - name: dbeaver-sources-global-configmap<br>    files:<br>      - dbeaver/configs/global/data-sources.json<br>  - name: dbeaver-server-configmap<br>    files:<br>      - dbeaver/configs/cloudbeaver.conf</pre><p>Após aplicado</p><pre>❯ kubectl get configmaps<br>NAME                                          DATA   AGE<br>dbeaver-product-configmap-kg79td7884          1      3d15h<br>dbeaver-server-configmap-m5fc6m9ff7           1      3d15h<br>dbeaver-sources-global-configmap-9b82g2h9bm   1      3d15h<br>dbeaver-sources-user-configmap-5d7fttct9h     1      3d15h</pre><p>Para usar esses <em>configMaps,</em> devemos criar os volumes com eles no <em>deployment</em>, veja a seguir:</p><p><em>deployment.yaml:</em></p><pre>volumes:<br>        - name: volume-name<br>          configMap:<br>            name: configmap-name</pre><p>Exemplo na prática:</p><pre>volumes:<br>        - name: dbeaver-product<br>          configMap:<br>            name: dbeaver-product-configmap<br>        - name: dbeaver-sources-user<br>          configMap:<br>            name: dbeaver-sources-user-configmap<br>        - name: dbeaver-sources-global<br>          configMap:<br>            name: dbeaver-sources-global-configmap<br>        - name: dbeaver-server<br>          configMap:<br>            name: dbeaver-server-configmap</pre><p>Com os volumes declarados, podemos agora montar eles:</p><pre>volumeMounts:<br>            - name: volume-name<br>              mountPath: /path/inside/container/to/your/file.conf<br>              subPath: file.conf</pre><p>Exemplo na prática:</p><pre>volumeMounts:<br>            - name: dbeaver-product<br>              mountPath: /opt/cloudbeaver/conf/product.conf<br>              subPath: product.conf<br>            - name: dbeaver-sources-user<br>              mountPath: /opt/cloudbeaver/workspace/user-projects/admin.dbeaver/.dbeaver/data-sources.json<br>              subPath: data-sources.json<br>            - name: dbeaver-sources-global<br>              mountPath: /opt/cloudbeaver/workspace/GlobalConfiguration/.dbeaver/data-sources.json<br>              subPath: data-sources.json<br>            - name: dbeaver-server<br>              mountPath: /opt/cloudbeaver/conf/cloudbeaver.conf<br>              subPath: cloudbeaver.conf</pre><p>No final o arquivo <em>deployment.yaml</em> (cloudbeaver) deve ficar assim:</p><pre>kind: Deployment<br>apiVersion: apps/v1<br>metadata:<br>  name: dbeaver<br>  namespace: cloud-beaver-test<br>spec:<br>  progressDeadlineSeconds: 600<br>  replicas: 1<br>  revisionHistoryLimit: 1<br>  strategy:<br>    rollingUpdate:<br>      maxSurge: 1<br>      maxUnavailable: 0<br>    type: RollingUpdate<br>  selector:<br>    matchLabels:<br>      app: dbeaver-app<br>  template:<br>    metadata:<br>      labels:<br>        app: dbeaver-app<br>    spec:<br>      containers:<br>        - name: dbeaver<br>          image: dbeaver/cloudbeaver:latest<br>          imagePullPolicy: Always<br>          resources:<br>            requests:<br>              cpu: 200m<br>              memory: 256Mi<br>            limits:<br>              cpu: 500m<br>              memory: 256Mi<br>          ports:<br>            - name: web-access<br>              containerPort: 8978<br>          livenessProbe:<br>            httpGet:<br>              path: /<br>              port: 8978<br>              scheme: HTTP<br>            initialDelaySeconds: 300<br>            timeoutSeconds: 10<br>            periodSeconds: 300<br>            successThreshold: 1<br>            failureThreshold: 5<br>          envFrom:<br>          - secretRef:<br>              name: dbeaver-secret<br>          volumeMounts:<br>            - name: dbeaver-product<br>              mountPath: /opt/cloudbeaver/conf/product.conf<br>              subPath: product.conf<br>            - name: dbeaver-sources-user<br>              mountPath: /opt/cloudbeaver/workspace/user-projects/admin.dbeaver/.dbeaver/data-sources.json<br>              subPath: data-sources.json<br>            - name: dbeaver-sources-global<br>              mountPath: /opt/cloudbeaver/workspace/GlobalConfiguration/.dbeaver/data-sources.json<br>              subPath: data-sources.json<br>            - name: dbeaver-server<br>              mountPath: /opt/cloudbeaver/conf/cloudbeaver.conf<br>              subPath: cloudbeaver.conf<br>      volumes:<br>        - name: dbeaver-product<br>          configMap:<br>            name: dbeaver-product-configmap<br>        - name: dbeaver-sources-user<br>          configMap:<br>            name: dbeaver-sources-user-configmap<br>        - name: dbeaver-sources-global<br>          configMap:<br>            name: dbeaver-sources-global-configmap<br>        - name: dbeaver-server<br>          configMap:<br>            name: dbeaver-server-configmap</pre><p>E o <em>kustomization.yaml</em> (parte do cloudbeaver) assim:</p><pre>apiVersion: kustomize.config.k8s.io/v1beta1<br>kind: Kustomization<br>namespace: cloud-beaver-test<br>resources:<br>  - namespace.yaml<br>  - dbeaver/deployment.yaml<br>  - dbeaver/service.yaml<br>  - postgres/deployment.yaml<br>  - postgres/service.yaml<br>  - mysql/deployment.yaml<br>  - mysql/service.yaml<br><br>configMapGenerator:<br>#DBEAVER<br>  - name: dbeaver-product-configmap<br>    files:<br>      - dbeaver/configs/product.conf<br>  - name: dbeaver-sources-user-configmap<br>    files:<br>      - dbeaver/configs/user/data-sources.json<br>  - name: dbeaver-sources-global-configmap<br>    files:<br>      - dbeaver/configs/global/data-sources.json<br>  - name: dbeaver-server-configmap<br>    files:<br>      - dbeaver/configs/cloudbeaver.conf<br>#POSTGRES<br>  - name: postgres-configmap<br>    literals:<br>    - POSTGRES_USER=my-db-user<br>    - POSTGRES_PASSWORD=Password123<br>    - POSTGRES_DB=my-postgre-db<br>#MYSQL<br>  - name: mysql-configmap<br>    literals:<br>    - MYSQL_ROOT_PASSWORD=PasswordROOT<br>    - MYSQL_USER=my-db-user<br>    - MYSQL_PASSWORD=Password123<br>    - MYSQL_DATABASE=my-mysql-db<br><br>secretGenerator:<br>#DBEAVER<br>- name: dbeaver-secret<br>  literals:<br>    - CB_SERVER_NAME=CloudBeaver Test Server<br>    - CB_ADMIN_NAME=admin.dbeaver<br>    - CB_ADMIN_PASSWORD=Password123<br><br>commonLabels:<br>  kubernetes.io/environment: dev</pre><p>Obs: esses <em>secrets</em> gerados no <em>kustomization.yaml</em> são variáveis do CloudBeaver onde:</p><pre>CB_SERVER_NAME=Server name<br>CB_ADMIN_NAME=&lt;admin user&gt;<br>CB_ADMIN_PASSWORD=&lt;yourpasswordhere&gt;</pre><p>Agora que já sabemos como configurar, vamos entender para que serve esses 3 arquivos: <em>data-sources.json, cloudbeaver.conf, product.conf</em></p><h3>data-sources.json</h3><p>Neste arquivo é onde realizamos as configurações de conexão para as instâncias de banco de dados. No exemplo vamos usar conexões para um banco Postgres e outro MySql.</p><p>Ele está localizado da seguinte maneira:</p><p><strong><em>/opt/cloudbeaver/workspace/user-projects/&lt;USER&gt;/.dbeaver/data-sources.json</em></strong></p><p>Aqui são as configurações do usuário em questão, só ficarão disponíveis as conexões após login no CloudBeaver.</p><p><strong><em>/opt/cloudbeaver/workspace/GlobalConfiguration/.dbeaver/data-sources.json</em></strong></p><p>Como o nome da pasta já diz, são as configs globais, todas as configurações aqui feitas ficarão disponíveis sem autenticação no CloudBeaver, caso você habilite o acesso anônimo.</p><p>Vou explicar os principais parâmetros deste JSON para que você consiga configurar sem problemas:</p><p>“<strong>folders</strong>”: Caso você queria configurar várias conexões, pode separar em pastas.</p><p>“<strong>save-password</strong>”: Melhor não salvar a senha de acesso ao seu banco de dados né? (deixe em false)</p><p>“<strong>folder</strong>”: caso tenha criado pasta, declare ela aqui.</p><p>“<strong>user</strong>”: Usuário do banco de dados, caso você declare aqui, ele vai auto completar para você na tela de login.</p><p>“<strong>host</strong>”: IP ou endereço DNS da sua instancia de banco de dados.</p><p>“<strong>port</strong>”: Porta de acesso ao banco de dados.</p><p>“<strong>database</strong>”: Banco de dados que será realizada a comunicação.</p><p>“<strong>url</strong>”: A url é composta dos seguintes parâmetros &lt;provider&gt;://&lt;host&gt;:&lt;port&gt;/&lt;database&gt;</p><pre>{<br> &quot;folders&quot;: {<br>  &quot;My DBs&quot;: {}<br> },<br> &quot;connections&quot;: {<br>  &quot;DB-example-01&quot;: {<br>   &quot;provider&quot;: &quot;postgresql&quot;,<br>   &quot;driver&quot;: &quot;postgres-jdbc&quot;,<br>   &quot;name&quot;: &quot;DB-example-01&quot;,<br>   &quot;description&quot;: &quot;Postgre connection&quot;,<br>   &quot;save-password&quot;: false,<br>   &quot;show-system-objects&quot;: true,<br>   &quot;read-only&quot;: false,<br>   &quot;folder&quot;: &quot;My DBs&quot;,<br>   &quot;configuration&quot;: {<br>    &quot;user&quot;: &quot;my-db-user&quot;,<br>    &quot;host&quot;: &quot;postgres&quot;,<br>    &quot;port&quot;: &quot;5432&quot;,<br>    &quot;database&quot;: &quot;my-postgre-db&quot;,<br>    &quot;url&quot;: &quot;jdbc:postgresql://postgres:5432/my-postgre-db&quot;,<br>    &quot;type&quot;: &quot;dev&quot;,<br>    &quot;provider-properties&quot;: {<br>     &quot;@dbeaver-show-non-default-db@&quot;: &quot;true&quot;<br>    },<br>    &quot;auth-model&quot;: &quot;native&quot;<br>   }<br>  },<br>  &quot;DB-example-02&quot;: {<br>   &quot;provider&quot;: &quot;mysql&quot;,<br>   &quot;driver&quot;: &quot;mysql8&quot;,<br>   &quot;name&quot;: &quot;DB-example-02&quot;,<br>   &quot;description&quot;: &quot;&quot;,<br>   &quot;save-password&quot;: false,<br>   &quot;show-system-objects&quot;: true,<br>   &quot;read-only&quot;: false,<br>   &quot;folder&quot;: &quot;My DBs&quot;,<br>   &quot;configuration&quot;: {<br>    &quot;user&quot;: &quot;my-db-user&quot;,<br>    &quot;host&quot;: &quot;mysql&quot;,<br>    &quot;port&quot;: &quot;3306&quot;,<br>    &quot;database&quot;: &quot;my-mysql-db&quot;,<br>    &quot;url&quot;: &quot;jdbc:mysql://mysql:3306/my-mysql-db&quot;,<br>    &quot;type&quot;: &quot;dev&quot;,<br>    &quot;properties&quot;: {<br>     &quot;allowPublicKeyRetrieval&quot;: &quot;true&quot;<br>    },<br>    &quot;provider-properties&quot;: {<br>     &quot;@dbeaver-show-non-default-db@&quot;: &quot;false&quot;<br>    },<br>    &quot;auth-model&quot;: &quot;native&quot;<br>   }<br>  }<br> },<br> &quot;connection-types&quot;: {<br>  &quot;dev&quot;: {<br>   &quot;name&quot;: &quot;Development&quot;,<br>   &quot;color&quot;: &quot;0,0,255&quot;,<br>   &quot;description&quot;: &quot;Regular development database&quot;,<br>   &quot;auto-commit&quot;: true,<br>   &quot;confirm-execute&quot;: false,<br>   &quot;confirm-data-change&quot;: false,<br>   &quot;auto-close-transactions&quot;: false<br>  }<br> }<br>}</pre><h3>cloudbeaver.conf</h3><p><em>/opt/cloudbeaver/conf/product.conf</em></p><p>Aqui temos diversas configurações gerais da instância do CloudBeaver</p><p>Vou destacar as que acho importante:</p><p>“<strong>anonymousAccessEnabled</strong>”: Onde definimos se terá acesso anônimo ou não. (Deixe em false).</p><p>“<strong>publicCredentialsSaveEnabled</strong>”: Deixe em false, não preciso dizer porque.</p><p>“<strong>adminCredentialsSaveEnabled</strong>”: Deixe em false, não preciso dizer porque.</p><pre>{<br>    server: {<br>        serverPort: 8978,<br>        workspaceLocation: &quot;workspace&quot;,<br>        contentRoot: &quot;web&quot;,<br>        driversLocation: &quot;drivers&quot;,<br>        rootURI: &quot;/&quot;,<br>        serviceURI: &quot;/api/&quot;,<br>        productConfiguration: &quot;conf/product.conf&quot;,<br>        expireSessionAfterPeriod: 1800000,<br>        develMode: false,<br>        enableSecurityManager: false,<br>        database: {<br>            driver=&quot;h2_embedded&quot;,<br>            url: &quot;jdbc:h2:${workspace}/.data/cb.h2.dat&quot;,<br>            createDatabase: true,<br>            initialDataConfiguration: &quot;conf/initial-data.conf&quot;,<br>            pool: {<br>                minIdleConnections: 4,<br>                maxIdleConnections: 10,<br>                maxConnections: 100,<br>                validationQuery: &quot;SELECT 1&quot;<br>            }<br>        }<br>    },<br>    app: {<br>        anonymousAccessEnabled: false,<br>        anonymousUserRole: &quot;user&quot;,<br>        supportsCustomConnections: false,<br>        forwardProxy: false,<br>        publicCredentialsSaveEnabled: false,<br>        adminCredentialsSaveEnabled: false,<br>        resourceManagerEnabled: true,<br>        resourceQuotas: {<br>            dataExportFileSizeLimit: 10000000,<br>            resourceManagerFileSizeLimit: 500000,<br>            sqlMaxRunningQueries: 100,<br>            sqlResultSetRowsLimit: 100000,<br>            sqlResultSetMemoryLimit: 2000000,<br>            sqlTextPreviewMaxLength: 4096,<br>            sqlBinaryPreviewMaxLength: 261120<br>        },<br>        enabledAuthProviders: [<br>            &quot;local&quot;<br>        ],<br>        disabledDrivers: [<br>            &quot;sqlite:sqlite_jdbc&quot;,<br>            &quot;h2:h2_embedded&quot;,<br>            &quot;clickhouse:yandex_clickhouse&quot;<br>        ]<br>    }<br>}</pre><h3>product.conf</h3><p><em>/opt/cloudbeaver/conf/product.conf</em></p><p>Algumas configurações de personalização você encontra aqui, fiz alterações somente nestas abaixo:</p><p>“<strong>defaultTheme</strong>”: Definição do tema, sugiro “dark”.</p><p>“<strong>defaultLanguage</strong>”: “en”</p><pre>// Product configuration. Customized web application behavior<br>// It is in JSONC format<br>{<br>    // Global properties<br>    core: {<br>        // User defaults<br>        user: {<br>            defaultTheme: &quot;dark&quot;,<br>            defaultLanguage: &quot;en&quot;<br>        },<br>        app: {<br>            // Log viewer config<br>            logViewer: {<br>                refreshTimeout: 3000,<br>                logBatchSize: 1000,<br>                maxLogRecords: 2000,<br>                maxFailedRequests: 3<br>            }<br>        },<br>        authentication: {<br>            anonymousAccessEnabled: false<br>        }<br>    },<br>    // Notifications config<br>    core_events: {<br>        notificationsPool: 5<br>    },<br>    plugin_data_spreadsheet_new: {<br>        hidden: false<br>    },<br>    plugin_data_export: {<br>        disabled: false<br>    }<br>}</pre><h3>Mãos à obra</h3><p>Agora de posse dessas informações vamos colocar em prática usando alguns pods de banco de dados.</p><p>Clone o repositório, entre na pasta e execute o comando</p><pre>❯ kubectl apply -k .</pre><p>Esse comando irá ler o arquivo <em>kustomization.yaml</em> e aplicar todas as specs, configurações, variáveis e <em>configMaps</em> que estão declaradas nele.</p><p>Saída do comando :</p><pre>❯ kubectl apply -k k8s<br>namespace/cloud-beaver-test created<br>configmap/dbeaver-product-configmap-kg79td7884 created<br>configmap/dbeaver-server-configmap-m5fc6m9ff7 created<br>configmap/dbeaver-sources-global-configmap-9b82g2h9bm created<br>configmap/dbeaver-sources-user-configmap-5kf2gtc878 created<br>configmap/mysql-configmap-62g74m555t created<br>configmap/postgres-configmap-5kt6k78dkc created<br>secret/dbeaver-secret-b8bmc6h476 created<br>service/dbeaver created<br>service/mysql created<br>service/postgres created<br>deployment.apps/dbeaver created<br>deployment.apps/mysql created<br>deployment.apps/postgres created</pre><p>Verifique se tudo subiu corretamente e faça um <em>port-forward</em> no pod do CloudBeaver para testar:</p><pre>❯ kubectl port-forward -n cloud-beaver-test pods/dbeaver-7958f5b776-rk9qh 9090:8978</pre><p>Faça login no CloudBeaver e deve aparecer assim se tudo estiver correto principalmente com o arquivo <em>data-sources.json</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*KTxjMa8oSbaTO-Wmwa6XBw.png" /><figcaption>CloudBeaver Connections</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12b62e4a3d30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/totvsdevelopers/configurando-acesso-a-banco-de-dados-com-o-cloudbeaver-no-kubernetes-12b62e4a3d30">Configurando acesso a banco de dados com o CloudBeaver no Kubernetes</a> was originally published in <a href="https://medium.com/totvsdevelopers">TOTVS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>