From 72267ac653724cddcd503adb97b64c5154250ad5 Mon Sep 17 00:00:00 2001 From: edsoncelio Date: Sun, 2 May 2021 10:30:34 -0300 Subject: [PATCH 1/5] Add initial files to translate the secret task --- .../docs/tasks/configmap-secret/_index.md | 6 + .../managing-secret-using-config-file.md | 198 ++++++++++++++++++ .../managing-secret-using-kubectl.md | 156 ++++++++++++++ .../managing-secret-using-kustomize.md | 128 +++++++++++ .../pt-br/includes/task-tutorial-prereqs.md | 8 + 5 files changed, 496 insertions(+) create mode 100755 content/pt-br/docs/tasks/configmap-secret/_index.md create mode 100644 content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md create mode 100644 content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md create mode 100644 content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md create mode 100644 content/pt-br/includes/task-tutorial-prereqs.md diff --git a/content/pt-br/docs/tasks/configmap-secret/_index.md b/content/pt-br/docs/tasks/configmap-secret/_index.md new file mode 100755 index 0000000000..d80692c967 --- /dev/null +++ b/content/pt-br/docs/tasks/configmap-secret/_index.md @@ -0,0 +1,6 @@ +--- +title: "Managing Secrets" +weight: 28 +description: Managing confidential settings data using Secrets. +--- + diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md new file mode 100644 index 0000000000..b405d57baf --- /dev/null +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md @@ -0,0 +1,198 @@ +--- +title: Managing Secret using Configuration File +content_type: task +weight: 20 +description: Creating Secret objects using resource configuration file. +--- + + + +## {{% heading "prerequisites" %}} + +{{< include "task-tutorial-prereqs.md" >}} + + + +## Create the Config file + +You can create a Secret in a file first, in JSON or YAML format, and then +create that object. The +[Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core) +resource contains two maps: `data` and `stringData`. +The `data` field is used to store arbitrary data, encoded using base64. The +`stringData` field is provided for convenience, and it allows you to provide +Secret data as unencoded strings. +The keys of `data` and `stringData` must consist of alphanumeric characters, +`-`, `_` or `.`. + +For example, to store two strings in a Secret using the `data` field, convert +the strings to base64 as follows: + +```shell +echo -n 'admin' | base64 +``` + +The output is similar to: + +``` +YWRtaW4= +``` + +```shell +echo -n '1f2d1e2e67df' | base64 +``` + +The output is similar to: + +``` +MWYyZDFlMmU2N2Rm +``` + +Write a Secret config file that looks like this: + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: mysecret +type: Opaque +data: + username: YWRtaW4= + password: MWYyZDFlMmU2N2Rm +``` + +Note that the name of a Secret object must be a valid +[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names). + +{{< note >}} +The serialized JSON and YAML values of Secret data are encoded as base64 +strings. Newlines are not valid within these strings and must be omitted. When +using the `base64` utility on Darwin/macOS, users should avoid using the `-b` +option to split long lines. Conversely, Linux users *should* add the option +`-w 0` to `base64` commands or the pipeline `base64 | tr -d '\n'` if the `-w` +option is not available. +{{< /note >}} + +For certain scenarios, you may wish to use the `stringData` field instead. This +field allows you to put a non-base64 encoded string directly into the Secret, +and the string will be encoded for you when the Secret is created or updated. + +A practical example of this might be where you are deploying an application +that uses a Secret to store a configuration file, and you want to populate +parts of that configuration file during your deployment process. + +For example, if your application uses the following configuration file: + +```yaml +apiUrl: "https://my.api.com/api/v1" +username: "" +password: "" +``` + +You could store this in a Secret using the following definition: + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: mysecret +type: Opaque +stringData: + config.yaml: | + apiUrl: "https://my.api.com/api/v1" + username: + password: +``` + +## Create the Secret object + +Now create the Secret using [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply): + +```shell +kubectl apply -f ./secret.yaml +``` + +The output is similar to: + +``` +secret/mysecret created +``` + +## Check the Secret + +The `stringData` field is a write-only convenience field. It is never output when +retrieving Secrets. For example, if you run the following command: + +```shell +kubectl get secret mysecret -o yaml +``` + +The output is similar to: + +```yaml +apiVersion: v1 +kind: Secret +metadata: + creationTimestamp: 2018-11-15T20:40:59Z + name: mysecret + namespace: default + resourceVersion: "7225" + uid: c280ad2e-e916-11e8-98f2-025000000001 +type: Opaque +data: + config.yaml: YXBpVXJsOiAiaHR0cHM6Ly9teS5hcGkuY29tL2FwaS92MSIKdXNlcm5hbWU6IHt7dXNlcm5hbWV9fQpwYXNzd29yZDoge3twYXNzd29yZH19 +``` + +The commands `kubectl get` and `kubectl describe` avoid showing the contents of a `Secret` by +default. This is to protect the `Secret` from being exposed accidentally to an onlooker, +or from being stored in a terminal log. +To check the actual content of the encoded data, please refer to +[decoding secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret). + +If a field, such as `username`, is specified in both `data` and `stringData`, +the value from `stringData` is used. For example, the following Secret definition: + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: mysecret +type: Opaque +data: + username: YWRtaW4= +stringData: + username: administrator +``` + +Results in the following Secret: + +```yaml +apiVersion: v1 +kind: Secret +metadata: + creationTimestamp: 2018-11-15T20:46:46Z + name: mysecret + namespace: default + resourceVersion: "7579" + uid: 91460ecb-e917-11e8-98f2-025000000001 +type: Opaque +data: + username: YWRtaW5pc3RyYXRvcg== +``` + +Where `YWRtaW5pc3RyYXRvcg==` decodes to `administrator`. + +## Clean Up + +To delete the Secret you have created: + +```shell +kubectl delete secret mysecret +``` + +## {{% heading "whatsnext" %}} + +- Read more about the [Secret concept](/docs/concepts/configuration/secret/) +- Learn how to [manage Secret with the `kubectl` command](/docs/tasks/configmap-secret/managing-secret-using-kubectl/) +- Learn how to [manage Secret using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/) + diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md new file mode 100644 index 0000000000..293915736e --- /dev/null +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md @@ -0,0 +1,156 @@ +--- +title: Managing Secret using kubectl +content_type: task +weight: 10 +description: Creating Secret objects using kubectl command line. +--- + + + +## {{% heading "prerequisites" %}} + +{{< include "task-tutorial-prereqs.md" >}} + + + +## Create a Secret + +A `Secret` can contain user credentials required by Pods to access a database. +For example, a database connection string consists of a username and password. +You can store the username in a file `./username.txt` and the password in a +file `./password.txt` on your local machine. + +```shell +echo -n 'admin' > ./username.txt +echo -n '1f2d1e2e67df' > ./password.txt +``` + +The `-n` flag in the above two commands ensures that the generated files will +not contain an extra newline character at the end of the text. This is +important because when `kubectl` reads a file and encode the content into +base64 string, the extra newline character gets encoded too. + +The `kubectl create secret` command packages these files into a Secret and creates +the object on the API server. + +```shell +kubectl create secret generic db-user-pass \ + --from-file=./username.txt \ + --from-file=./password.txt +``` + +The output is similar to: + +``` +secret/db-user-pass created +``` + +Default key name is the filename. You may optionally set the key name using +`--from-file=[key=]source`. For example: + +```shell +kubectl create secret generic db-user-pass \ + --from-file=username=./username.txt \ + --from-file=password=./password.txt +``` + +You do not need to escape special characters in passwords from files +(`--from-file`). + +You can also provide Secret data using the `--from-literal==` tag. +This tag can be specified more than once to provide multiple key-value pairs. +Note that special characters such as `$`, `\`, `*`, `=`, and `!` will be +interpreted by your [shell](https://en.wikipedia.org/wiki/Shell_(computing)) +and require escaping. +In most shells, the easiest way to escape the password is to surround it with +single quotes (`'`). For example, if your actual password is `S!B\*d$zDsb=`, +you should execute the command this way: + +```shell +kubectl create secret generic dev-db-secret \ + --from-literal=username=devuser \ + --from-literal=password='S!B\*d$zDsb=' +``` + +## Verify the Secret + +You can check that the secret was created: + +```shell +kubectl get secrets +``` + +The output is similar to: + +``` +NAME TYPE DATA AGE +db-user-pass Opaque 2 51s +``` + +You can view a description of the `Secret`: + +```shell +kubectl describe secrets/db-user-pass +``` + +The output is similar to: + +``` +Name: db-user-pass +Namespace: default +Labels: +Annotations: + +Type: Opaque + +Data +==== +password: 12 bytes +username: 5 bytes +``` + +The commands `kubectl get` and `kubectl describe` avoid showing the contents +of a `Secret` by default. This is to protect the `Secret` from being exposed +accidentally to an onlooker, or from being stored in a terminal log. + +## Decoding the Secret {#decoding-secret} + +To view the contents of the Secret you created, run the following command: + +```shell +kubectl get secret db-user-pass -o jsonpath='{.data}' +``` + +The output is similar to: + +```json +{"password":"MWYyZDFlMmU2N2Rm","username":"YWRtaW4="} +``` + +Now you can decode the `password` data: + +```shell +echo 'MWYyZDFlMmU2N2Rm' | base64 --decode +``` + +The output is similar to: + +``` +1f2d1e2e67df +``` + +## Clean Up + +To delete the Secret you have created: + +```shell +kubectl delete secret db-user-pass +``` + + + +## {{% heading "whatsnext" %}} + +- Read more about the [Secret concept](/docs/concepts/configuration/secret/) +- Learn how to [manage Secret using config file](/docs/tasks/configmap-secret/managing-secret-using-config-file/) +- Learn how to [manage Secret using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/) diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md new file mode 100644 index 0000000000..fb257a6026 --- /dev/null +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md @@ -0,0 +1,128 @@ +--- +title: Managing Secret using Kustomize +content_type: task +weight: 30 +description: Creating Secret objects using kustomization.yaml file. +--- + + + +Since Kubernetes v1.14, `kubectl` supports +[managing objects using Kustomize](/docs/tasks/manage-kubernetes-objects/kustomization/). +Kustomize provides resource Generators to create Secrets and ConfigMaps. The +Kustomize generators should be specified in a `kustomization.yaml` file inside +a directory. After generating the Secret, you can create the Secret on the API +server with `kubectl apply`. + +## {{% heading "prerequisites" %}} + +{{< include "task-tutorial-prereqs.md" >}} + + + +## Create the Kustomization file + +You can generate a Secret by defining a `secretGenerator` in a +`kustomization.yaml` file that references other existing files. +For example, the following kustomization file references the +`./username.txt` and the `./password.txt` files: + +```yaml +secretGenerator: +- name: db-user-pass + files: + - username.txt + - password.txt +``` + +You can also define the `secretGenerator` in the `kustomization.yaml` +file by providing some literals. +For example, the following `kustomization.yaml` file contains two literals +for `username` and `password` respectively: + +```yaml +secretGenerator: +- name: db-user-pass + literals: + - username=admin + - password=1f2d1e2e67df +``` + +Note that in both cases, you don't need to base64 encode the values. + +## Create the Secret + +Apply the directory containing the `kustomization.yaml` to create the Secret. + +```shell +kubectl apply -k . +``` + +The output is similar to: + +``` +secret/db-user-pass-96mffmfh4k created +``` + +Note that when a Secret is generated, the Secret name is created by hashing +the Secret data and appending the hash value to the name. This ensures that +a new Secret is generated each time the data is modified. + +## Check the Secret created + +You can check that the secret was created: + +```shell +kubectl get secrets +``` + +The output is similar to: + +``` +NAME TYPE DATA AGE +db-user-pass-96mffmfh4k Opaque 2 51s +``` + +You can view a description of the secret: + +```shell +kubectl describe secrets/db-user-pass-96mffmfh4k +``` + +The output is similar to: + +``` +Name: db-user-pass-96mffmfh4k +Namespace: default +Labels: +Annotations: + +Type: Opaque + +Data +==== +password.txt: 12 bytes +username.txt: 5 bytes +``` + +The commands `kubectl get` and `kubectl describe` avoid showing the contents of a `Secret` by +default. This is to protect the `Secret` from being exposed accidentally to an onlooker, +or from being stored in a terminal log. +To check the actual content of the encoded data, please refer to +[decoding secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret). + +## Clean Up + +To delete the Secret you have created: + +```shell +kubectl delete secret db-user-pass-96mffmfh4k +``` + + +## {{% heading "whatsnext" %}} + +- Read more about the [Secret concept](/docs/concepts/configuration/secret/) +- Learn how to [manage Secret with the `kubectl` command](/docs/tasks/configmap-secret/managing-secret-using-kubectl/) +- Learn how to [manage Secret using config file](/docs/tasks/configmap-secret/managing-secret-using-config-file/) + diff --git a/content/pt-br/includes/task-tutorial-prereqs.md b/content/pt-br/includes/task-tutorial-prereqs.md new file mode 100644 index 0000000000..93195d8b9c --- /dev/null +++ b/content/pt-br/includes/task-tutorial-prereqs.md @@ -0,0 +1,8 @@ +You need to have a Kubernetes cluster, and the kubectl command-line tool must +be configured to communicate with your cluster. If you do not already have a +cluster, you can create one by using +[minikube](/docs/tasks/tools/#minikube) +or you can use one of these Kubernetes playgrounds: + +* [Katacoda](https://www.katacoda.com/courses/kubernetes/playground) +* [Play with Kubernetes](http://labs.play-with-k8s.com/) From 0a5d839101f4f4aa96963f5a406741db64daf841 Mon Sep 17 00:00:00 2001 From: edsoncelio Date: Sun, 16 May 2021 09:12:38 -0300 Subject: [PATCH 2/5] Update task secret translation --- .../pt-br/docs/tasks/configmap-secret/_index.md | 4 ++-- .../managing-secret-using-kustomize.md | 15 ++++++--------- content/pt-br/includes/task-tutorial-prereqs.md | 10 ++++------ 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/content/pt-br/docs/tasks/configmap-secret/_index.md b/content/pt-br/docs/tasks/configmap-secret/_index.md index d80692c967..81ee33267b 100755 --- a/content/pt-br/docs/tasks/configmap-secret/_index.md +++ b/content/pt-br/docs/tasks/configmap-secret/_index.md @@ -1,6 +1,6 @@ --- -title: "Managing Secrets" +title: "Gerenciando Secrets" weight: 28 -description: Managing confidential settings data using Secrets. +description: Gerenciando dados de configurações confidencias usando Secrets. --- diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md index fb257a6026..f926c95f30 100644 --- a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md @@ -1,19 +1,16 @@ --- -title: Managing Secret using Kustomize +title: Gerenciando Secret usando Kustomize content_type: task weight: 30 -description: Creating Secret objects using kustomization.yaml file. +description: Criando objetos Secret usando o arquivo kustomization.yaml --- -Since Kubernetes v1.14, `kubectl` supports -[managing objects using Kustomize](/docs/tasks/manage-kubernetes-objects/kustomization/). -Kustomize provides resource Generators to create Secrets and ConfigMaps. The -Kustomize generators should be specified in a `kustomization.yaml` file inside -a directory. After generating the Secret, you can create the Secret on the API -server with `kubectl apply`. - +Desde o Kubernetes v1.14, o `kubectl` provê suporte para [gerenciamento de objetos usando Kustomize](/docs/tasks/manage-kubernetes-objects/kustomization/). +O Kustomize provê geradores de recursos para criar Secrets e ConfigMaps. +Os geradores Kustomize devem ser especificados em um arquivo `kustomization.yaml` dentro +de um diretório. Depois de gerar o Secret, você pode criar o Secret na API server com `kubectl apply`. ## {{% heading "prerequisites" %}} {{< include "task-tutorial-prereqs.md" >}} diff --git a/content/pt-br/includes/task-tutorial-prereqs.md b/content/pt-br/includes/task-tutorial-prereqs.md index 93195d8b9c..eb4177b4fd 100644 --- a/content/pt-br/includes/task-tutorial-prereqs.md +++ b/content/pt-br/includes/task-tutorial-prereqs.md @@ -1,8 +1,6 @@ -You need to have a Kubernetes cluster, and the kubectl command-line tool must -be configured to communicate with your cluster. If you do not already have a -cluster, you can create one by using -[minikube](/docs/tasks/tools/#minikube) -or you can use one of these Kubernetes playgrounds: - +Você precisa de um cluster Kubernetes e a ferramenta de linha de comando kubectl +precisa estar configurada para acessar o seu cluster. Se você ainda não tem um +cluster, pode criar um usando o [minikube](/docs/tasks/tools/#minikube) +ou você pode usar um dos seguintes ambientes: * [Katacoda](https://www.katacoda.com/courses/kubernetes/playground) * [Play with Kubernetes](http://labs.play-with-k8s.com/) From 9822c9a4dab53e147cf4e17969d0340e455ca85a Mon Sep 17 00:00:00 2001 From: edsoncelio Date: Fri, 9 Jul 2021 15:12:29 -0300 Subject: [PATCH 3/5] feat: add configmap-secret translation --- .../managing-secret-using-config-file.md | 107 +++++++++--------- .../managing-secret-using-kubectl.md | 88 +++++++------- .../managing-secret-using-kustomize.md | 63 +++++------ 3 files changed, 123 insertions(+), 135 deletions(-) diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md index b405d57baf..ffbeedee9e 100644 --- a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md @@ -1,8 +1,8 @@ --- -title: Managing Secret using Configuration File +title: Gerenciando Secret usando Arquivo de Configuração content_type: task weight: 20 -description: Creating Secret objects using resource configuration file. +description: Criando objetos Secret usando arquivos de configuração de recursos. --- @@ -13,26 +13,24 @@ description: Creating Secret objects using resource configuration file. -## Create the Config file +## Crie o arquivo de configuração -You can create a Secret in a file first, in JSON or YAML format, and then -create that object. The -[Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core) -resource contains two maps: `data` and `stringData`. -The `data` field is used to store arbitrary data, encoded using base64. The -`stringData` field is provided for convenience, and it allows you to provide -Secret data as unencoded strings. -The keys of `data` and `stringData` must consist of alphanumeric characters, -`-`, `_` or `.`. +Você pode criar um Secret primeiramente em um arquivo, no formato JSON ou YAML, e depois +criar o objeto. O recurso [Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core) +contém dois *maps*: `data` e `stringData`. +O campo `data` é usado para armazenar dados arbitrários, codificados usando base64. O +campo `stringData` é usado por conveniência, e permite que você use dados para um Secret +como *strings* não codificadas. +As chaves para `data` e `stringData` precisam ser compostas por caracteres alfanuméricos, +`_`, `-` ou `.`. -For example, to store two strings in a Secret using the `data` field, convert -the strings to base64 as follows: +Por exemplo, para armazenar duas strings em um Secret usando o campo `data`, converta +as strings para base64 da seguinte forma: ```shell echo -n 'admin' | base64 ``` - -The output is similar to: +A saída deve ser similar a: ``` YWRtaW4= @@ -42,14 +40,13 @@ YWRtaW4= echo -n '1f2d1e2e67df' | base64 ``` -The output is similar to: +A saída deve ser similar a: ``` MWYyZDFlMmU2N2Rm ``` -Write a Secret config file that looks like this: - +Escreva o arquivo de configuração do Secret, que ser parecido com: ```yaml apiVersion: v1 kind: Secret @@ -61,27 +58,26 @@ data: password: MWYyZDFlMmU2N2Rm ``` -Note that the name of a Secret object must be a valid -[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names). +Perceba que o nome do objeto Secret precisa ser um +[nome de subdomínio DNS](/docs/concepts/overview/working-with-objects/names#dns-subdomain-name) válido. {{< note >}} -The serialized JSON and YAML values of Secret data are encoded as base64 -strings. Newlines are not valid within these strings and must be omitted. When -using the `base64` utility on Darwin/macOS, users should avoid using the `-b` -option to split long lines. Conversely, Linux users *should* add the option -`-w 0` to `base64` commands or the pipeline `base64 | tr -d '\n'` if the `-w` -option is not available. +Os valores serializados dos dados JSON e YAML de um Secret são codificados em strings +base64. Novas linhas não são válidas com essas strings e devem ser omitidas. Quando +usar o utilitário `base64` em Darwin/MacOS, os usuários devem evitar usar a opção `-b` +para separar linhas grandes. Por outro lado, usuários de Linux *devem* adicionar a opção +`-w 0` ao comando `base64` ou o *pipe* `base64 | tr -d '\n'` se a opção `w` não for disponível {{< /note >}} -For certain scenarios, you may wish to use the `stringData` field instead. This -field allows you to put a non-base64 encoded string directly into the Secret, -and the string will be encoded for you when the Secret is created or updated. +Para cenários específicos, você pode querer usar o campo `stringData` ao invés de `data`. +Esse campo permite que você use strings não-base64 diretamente dentro do Secret, +e a string vai ser codificada para você quando o Secret for criado ou atualizado. -A practical example of this might be where you are deploying an application -that uses a Secret to store a configuration file, and you want to populate -parts of that configuration file during your deployment process. +Um exemplo prático para isso pode ser quando você esteja fazendo *deploy* de uma aplicação +que usa um Secret para armazenar um arquivo de configuração, e você quer popular partes desse +arquivo de configuração durante o processo de *deployment*. -For example, if your application uses the following configuration file: +Por exemplo, se sua aplicação usa o seguinte arquivo de configuração: ```yaml apiUrl: "https://my.api.com/api/v1" @@ -89,7 +85,7 @@ username: "" password: "" ``` -You could store this in a Secret using the following definition: +Você pode armazenar isso em um Secret usando a seguinte definição: ```yaml apiVersion: v1 @@ -104,30 +100,30 @@ stringData: password: ``` -## Create the Secret object +## Crie o objeto Secret -Now create the Secret using [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply): +Agora, crie o Secret usando [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply): ```shell kubectl apply -f ./secret.yaml ``` -The output is similar to: +A saída deve ser similar a: ``` secret/mysecret created ``` -## Check the Secret +## Verifique o Secret -The `stringData` field is a write-only convenience field. It is never output when -retrieving Secrets. For example, if you run the following command: +O campo `stringData` é um campo de conveniência apenas de leitura. Ele nunca vai ser exibido +ao buscar um Secret. Por exemplo, se você executar o seguinte comando: ```shell kubectl get secret mysecret -o yaml ``` -The output is similar to: +A saída deve ser similar a: ```yaml apiVersion: v1 @@ -143,14 +139,13 @@ data: config.yaml: YXBpVXJsOiAiaHR0cHM6Ly9teS5hcGkuY29tL2FwaS92MSIKdXNlcm5hbWU6IHt7dXNlcm5hbWV9fQpwYXNzd29yZDoge3twYXNzd29yZH19 ``` -The commands `kubectl get` and `kubectl describe` avoid showing the contents of a `Secret` by -default. This is to protect the `Secret` from being exposed accidentally to an onlooker, -or from being stored in a terminal log. -To check the actual content of the encoded data, please refer to -[decoding secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret). +Os comandos `kubectl get` e `kubectl describe` omitem o conteúdo de um `Secret` por padrão. +Isso para proteger o `Secret` de ser exposto acidentalmente para uma pessoa não autorizada, +ou ser armazenado em um log de terminal. +Para verificar o conteúdo atual de um dado codificado, veja [decodificando secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret). -If a field, such as `username`, is specified in both `data` and `stringData`, -the value from `stringData` is used. For example, the following Secret definition: +Se um campo, como `username`, é especificado em `data` e `stringData`, +o valor de `stringData` é o usado. Por exemplo, dado a seguinte definição do Secret: ```yaml apiVersion: v1 @@ -164,7 +159,7 @@ stringData: username: administrator ``` -Results in the following Secret: +Resulta no seguinte Secret: ```yaml apiVersion: v1 @@ -180,11 +175,11 @@ data: username: YWRtaW5pc3RyYXRvcg== ``` -Where `YWRtaW5pc3RyYXRvcg==` decodes to `administrator`. +Onde `YWRtaW5pc3RyYXRvcg==` é decodificado em `administrator`. -## Clean Up +## Limpeza -To delete the Secret you have created: +Para apagar o Secret que você criou: ```shell kubectl delete secret mysecret @@ -192,7 +187,7 @@ kubectl delete secret mysecret ## {{% heading "whatsnext" %}} -- Read more about the [Secret concept](/docs/concepts/configuration/secret/) -- Learn how to [manage Secret with the `kubectl` command](/docs/tasks/configmap-secret/managing-secret-using-kubectl/) -- Learn how to [manage Secret using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/) +- Leia mais sobre o [conceito do Secret](/docs/concepts/configuration/secret/) +- Leia sobre como [gerenciar Secret com o comando `kubectl`](/docs/tasks/configmap-secret/managing-secret-using-kubectl/) +- Leia sobre como [gerenciar Secret usando kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/) diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md index 293915736e..d8d98e007f 100644 --- a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md @@ -1,8 +1,8 @@ --- -title: Managing Secret using kubectl +title: kubectl Gerenciando Secret usando kubectl content_type: task weight: 10 -description: Creating Secret objects using kubectl command line. +description: Criando objetos Secret usando a linha de comando kubectl. --- @@ -13,25 +13,26 @@ description: Creating Secret objects using kubectl command line. -## Create a Secret +## Criando um Secret -A `Secret` can contain user credentials required by Pods to access a database. -For example, a database connection string consists of a username and password. -You can store the username in a file `./username.txt` and the password in a -file `./password.txt` on your local machine. +Um `Secret` pode conter credenciais de usuário requeridas por Pods para acesso a um banco de dados. +Por exemplo, uma string de conexão de banco de dados é composta por um usuário e senha. +Você pode armazenar o usuário em um arquivo `./username.txt` e a senha em um +arquivo `./password.txt` na sua máquina local. ```shell echo -n 'admin' > ./username.txt echo -n '1f2d1e2e67df' > ./password.txt ``` -The `-n` flag in the above two commands ensures that the generated files will -not contain an extra newline character at the end of the text. This is -important because when `kubectl` reads a file and encode the content into -base64 string, the extra newline character gets encoded too. +A opção `-n` nos comandos acima garante que os arquivos criados não vão conter +uma nova linha extra no final do arquivo de texto. Isso é importante porque +quando o `kubectl` lê um arquivo e codifica o conteúdo em uma string base64, +o caractere da nova linha extra também é codificado. + +O comando `kubectl create secret` empacota os arquivos em um Secret e cria um +objeto no API server. -The `kubectl create secret` command packages these files into a Secret and creates -the object on the API server. ```shell kubectl create secret generic db-user-pass \ @@ -39,32 +40,28 @@ kubectl create secret generic db-user-pass \ --from-file=./password.txt ``` -The output is similar to: +A saída deve ser similar a: ``` secret/db-user-pass created ``` -Default key name is the filename. You may optionally set the key name using -`--from-file=[key=]source`. For example: +O nome da chave padrão é o nome do arquivo. Opcionalmente, você pode definir +o nome da chave usando `--from-file=[key=]source`. Por exemplo: ```shell kubectl create secret generic db-user-pass \ --from-file=username=./username.txt \ --from-file=password=./password.txt ``` +Você não precisa escapar o caractere especial em senhas a partir de arquivos (`--from-file`). -You do not need to escape special characters in passwords from files -(`--from-file`). - -You can also provide Secret data using the `--from-literal==` tag. -This tag can be specified more than once to provide multiple key-value pairs. -Note that special characters such as `$`, `\`, `*`, `=`, and `!` will be -interpreted by your [shell](https://en.wikipedia.org/wiki/Shell_(computing)) -and require escaping. -In most shells, the easiest way to escape the password is to surround it with -single quotes (`'`). For example, if your actual password is `S!B\*d$zDsb=`, -you should execute the command this way: +Você também pode prover dados para Secret usando a tag `--from-literal==`. +Essa tag pode ser especificada mais de uma vez para prover múltiplos pares de chave-valor. +Observe que caracteres especiais como `$`, `\`, `*`, `=`, e `!` vão ser interpretados +pelo seu [shell](https://en.wikipedia.org/wiki/Shell_(computing)) e precisam ser escapados. +Na maioria dos shells, a forma mais fácil de escapar as senhas é usar aspas simples (`'`). +Por exemplo, se sua senha atual é `S!B\*d$zDsb=`, você precisa executar o comando dessa forma: ```shell kubectl create secret generic dev-db-secret \ @@ -72,28 +69,27 @@ kubectl create secret generic dev-db-secret \ --from-literal=password='S!B\*d$zDsb=' ``` -## Verify the Secret +## Verificando o Secret -You can check that the secret was created: +Você pode verificar se o secret foi criado: ```shell kubectl get secrets ``` -The output is similar to: +A saída deve ser similar a: ``` NAME TYPE DATA AGE db-user-pass Opaque 2 51s ``` -You can view a description of the `Secret`: +Você pode ver a descrição do `Secret`: ```shell kubectl describe secrets/db-user-pass ``` - -The output is similar to: +A saída deve ser similar a: ``` Name: db-user-pass @@ -109,39 +105,39 @@ password: 12 bytes username: 5 bytes ``` -The commands `kubectl get` and `kubectl describe` avoid showing the contents -of a `Secret` by default. This is to protect the `Secret` from being exposed -accidentally to an onlooker, or from being stored in a terminal log. +Os comandos `kubectl get` e `kubectl describe` omitem o conteúdo de um `Secret` por padrão. +Isso para proteger o `Secret` de ser exposto acidentalmente para uma pessoa não autorizada, +ou ser armazenado em um log de terminal. -## Decoding the Secret {#decoding-secret} +## Decodificando o Secret {#decoding-secret} -To view the contents of the Secret you created, run the following command: +Para ver o conteúdo de um Secret que você criou, execute o seguinte comando: ```shell kubectl get secret db-user-pass -o jsonpath='{.data}' ``` -The output is similar to: +A saída deve ser similar a: ```json {"password":"MWYyZDFlMmU2N2Rm","username":"YWRtaW4="} ``` -Now you can decode the `password` data: +Agora, você pode decodificar os dados de `password`: ```shell echo 'MWYyZDFlMmU2N2Rm' | base64 --decode ``` -The output is similar to: +A saída deve ser similar a: ``` 1f2d1e2e67df ``` -## Clean Up +## Limpeza -To delete the Secret you have created: +Para apagar o Secret que você criou: ```shell kubectl delete secret db-user-pass @@ -151,6 +147,6 @@ kubectl delete secret db-user-pass ## {{% heading "whatsnext" %}} -- Read more about the [Secret concept](/docs/concepts/configuration/secret/) -- Learn how to [manage Secret using config file](/docs/tasks/configmap-secret/managing-secret-using-config-file/) -- Learn how to [manage Secret using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/) +- Leia mais sobre o [conceito do Secret](/docs/concepts/configuration/secret/) +- Leia sobre como [gerenciar Secret com o comando `kubectl`](/docs/tasks/configmap-secret/managing-secret-using-kubectl/) +- Leia sobre como [gerenciar Secret usando kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/) diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md index f926c95f30..271a535de5 100644 --- a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md @@ -17,12 +17,11 @@ de um diretório. Depois de gerar o Secret, você pode criar o Secret na API ser -## Create the Kustomization file - -You can generate a Secret by defining a `secretGenerator` in a -`kustomization.yaml` file that references other existing files. -For example, the following kustomization file references the -`./username.txt` and the `./password.txt` files: +## Criando um arquivo de Kustomization +Você pode criar um Secret definindo um `secretGenerator` em um +arquivo `kustomization.yaml` que referencia outros arquivos existentes. +Por exemplo, o seguinte arquivo kustomization referencia os +arquivos `./username.txt` e `./password.txt`: ```yaml secretGenerator: @@ -32,10 +31,10 @@ secretGenerator: - password.txt ``` -You can also define the `secretGenerator` in the `kustomization.yaml` -file by providing some literals. -For example, the following `kustomization.yaml` file contains two literals -for `username` and `password` respectively: +Você também pode definir o `secretGenerator`no arquivo `kustomization.yaml` +por meio de alguns *literais*. +Por exemplo, o seguinte arquivo `kustomization.yaml` contém dois literais +para `username` e `password` respectivamente: ```yaml secretGenerator: @@ -45,48 +44,47 @@ secretGenerator: - password=1f2d1e2e67df ``` -Note that in both cases, you don't need to base64 encode the values. +Observe que nos dois casos, você não precisa codificar os valores em base64. -## Create the Secret +## Criando o Secret -Apply the directory containing the `kustomization.yaml` to create the Secret. +Aplique o diretório que contém o arquivo `kustomization.yaml` para criar o Secret. ```shell kubectl apply -k . ``` -The output is similar to: +A saída deve ser similar a: ``` secret/db-user-pass-96mffmfh4k created ``` -Note that when a Secret is generated, the Secret name is created by hashing -the Secret data and appending the hash value to the name. This ensures that -a new Secret is generated each time the data is modified. +Observe que quando um Secret é gerado, o nome do segredo é criado usando o hash +dos dados do Secret mais o valor do hash. Isso garante que +um novo Secret é gerado cada vez que os dados são modificados. -## Check the Secret created +## Verifique o Secret criado -You can check that the secret was created: +Você pode verificar que o secret foi criado: ```shell kubectl get secrets ``` -The output is similar to: +A saída deve ser similar a: ``` NAME TYPE DATA AGE db-user-pass-96mffmfh4k Opaque 2 51s ``` -You can view a description of the secret: +Você pode ver a descrição de um secret: ```shell kubectl describe secrets/db-user-pass-96mffmfh4k ``` - -The output is similar to: +A saída deve ser similar a: ``` Name: db-user-pass-96mffmfh4k @@ -102,15 +100,14 @@ password.txt: 12 bytes username.txt: 5 bytes ``` -The commands `kubectl get` and `kubectl describe` avoid showing the contents of a `Secret` by -default. This is to protect the `Secret` from being exposed accidentally to an onlooker, -or from being stored in a terminal log. -To check the actual content of the encoded data, please refer to -[decoding secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret). +Os comandos `kubectl get` e `kubectl describe` omitem o conteúdo de um `Secret` por padrão. +Isso para proteger o `Secret` de ser exposto acidentalmente para uma pessoa não autorizada, +ou ser armazenado em um log de terminal. +Para verificar o conteúdo atual de um dado codificado, veja [decodificando secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret). -## Clean Up +## Limpeza -To delete the Secret you have created: +Para apagar o Secret que você criou: ```shell kubectl delete secret db-user-pass-96mffmfh4k @@ -119,7 +116,7 @@ kubectl delete secret db-user-pass-96mffmfh4k ## {{% heading "whatsnext" %}} -- Read more about the [Secret concept](/docs/concepts/configuration/secret/) -- Learn how to [manage Secret with the `kubectl` command](/docs/tasks/configmap-secret/managing-secret-using-kubectl/) -- Learn how to [manage Secret using config file](/docs/tasks/configmap-secret/managing-secret-using-config-file/) +- Leia mais sobre o [conceito do Secret](/docs/concepts/configuration/secret/) +- Leia sobre como [gerenciar Secret com o comando `kubectl`](/docs/tasks/configmap-secret/managing-secret-using-kubectl/) +- Leia sobre como [gerenciar Secret usando kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/) From 7a0c7cae4693e20298150a90fefec95f4c8c195d Mon Sep 17 00:00:00 2001 From: edsoncelio Date: Fri, 9 Jul 2021 22:52:21 -0300 Subject: [PATCH 4/5] fix: fix typo in doc title --- .../tasks/configmap-secret/managing-secret-using-kubectl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md index d8d98e007f..7e6ca6dc7c 100644 --- a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kubectl.md @@ -1,5 +1,5 @@ --- -title: kubectl Gerenciando Secret usando kubectl +title: Gerenciando Secret usando kubectl content_type: task weight: 10 description: Criando objetos Secret usando a linha de comando kubectl. From fe63395af0c2367fab9dd4c496106e205300fa27 Mon Sep 17 00:00:00 2001 From: edsoncelio Date: Sat, 31 Jul 2021 15:09:11 -0300 Subject: [PATCH 5/5] feat: fix typos requested by code review --- content/pt-br/docs/tasks/configmap-secret/_index.md | 2 +- .../managing-secret-using-config-file.md | 10 +++++----- .../managing-secret-using-kustomize.md | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/content/pt-br/docs/tasks/configmap-secret/_index.md b/content/pt-br/docs/tasks/configmap-secret/_index.md index 81ee33267b..b12622f4fd 100755 --- a/content/pt-br/docs/tasks/configmap-secret/_index.md +++ b/content/pt-br/docs/tasks/configmap-secret/_index.md @@ -1,6 +1,6 @@ --- title: "Gerenciando Secrets" weight: 28 -description: Gerenciando dados de configurações confidencias usando Secrets. +description: Gerenciando dados de configurações usando Secrets. --- diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md index ffbeedee9e..0bac8410fa 100644 --- a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-config-file.md @@ -17,7 +17,7 @@ description: Criando objetos Secret usando arquivos de configuração de recurso Você pode criar um Secret primeiramente em um arquivo, no formato JSON ou YAML, e depois criar o objeto. O recurso [Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core) -contém dois *maps*: `data` e `stringData`. +contém dois mapas: `data` e `stringData`. O campo `data` é usado para armazenar dados arbitrários, codificados usando base64. O campo `stringData` é usado por conveniência, e permite que você use dados para um Secret como *strings* não codificadas. @@ -46,7 +46,7 @@ A saída deve ser similar a: MWYyZDFlMmU2N2Rm ``` -Escreva o arquivo de configuração do Secret, que ser parecido com: +Escreva o arquivo de configuração do Secret, que será parecido com: ```yaml apiVersion: v1 kind: Secret @@ -66,7 +66,7 @@ Os valores serializados dos dados JSON e YAML de um Secret são codificados em s base64. Novas linhas não são válidas com essas strings e devem ser omitidas. Quando usar o utilitário `base64` em Darwin/MacOS, os usuários devem evitar usar a opção `-b` para separar linhas grandes. Por outro lado, usuários de Linux *devem* adicionar a opção -`-w 0` ao comando `base64` ou o *pipe* `base64 | tr -d '\n'` se a opção `w` não for disponível +`-w 0` ao comando `base64` ou o *pipe* `base64 | tr -d '\n'` se a opção `w` não estiver disponível {{< /note >}} Para cenários específicos, você pode querer usar o campo `stringData` ao invés de `data`. @@ -75,7 +75,7 @@ e a string vai ser codificada para você quando o Secret for criado ou atualizad Um exemplo prático para isso pode ser quando você esteja fazendo *deploy* de uma aplicação que usa um Secret para armazenar um arquivo de configuração, e você quer popular partes desse -arquivo de configuração durante o processo de *deployment*. +arquivo de configuração durante o processo de implantação. Por exemplo, se sua aplicação usa o seguinte arquivo de configuração: @@ -145,7 +145,7 @@ ou ser armazenado em um log de terminal. Para verificar o conteúdo atual de um dado codificado, veja [decodificando secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret). Se um campo, como `username`, é especificado em `data` e `stringData`, -o valor de `stringData` é o usado. Por exemplo, dado a seguinte definição do Secret: +o valor de `stringData` é o usado. Por exemplo, dada a seguinte definição do Secret: ```yaml apiVersion: v1 diff --git a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md index 271a535de5..1658afc3de 100644 --- a/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md +++ b/content/pt-br/docs/tasks/configmap-secret/managing-secret-using-kustomize.md @@ -10,7 +10,7 @@ description: Criando objetos Secret usando o arquivo kustomization.yaml Desde o Kubernetes v1.14, o `kubectl` provê suporte para [gerenciamento de objetos usando Kustomize](/docs/tasks/manage-kubernetes-objects/kustomization/). O Kustomize provê geradores de recursos para criar Secrets e ConfigMaps. Os geradores Kustomize devem ser especificados em um arquivo `kustomization.yaml` dentro -de um diretório. Depois de gerar o Secret, você pode criar o Secret na API server com `kubectl apply`. +de um diretório. Depois de gerar o Secret, você pode criar o Secret com `kubectl apply`. ## {{% heading "prerequisites" %}} {{< include "task-tutorial-prereqs.md" >}} @@ -31,7 +31,7 @@ secretGenerator: - password.txt ``` -Você também pode definir o `secretGenerator`no arquivo `kustomization.yaml` +Você também pode definir o `secretGenerator` no arquivo `kustomization.yaml` por meio de alguns *literais*. Por exemplo, o seguinte arquivo `kustomization.yaml` contém dois literais para `username` e `password` respectivamente: