Skip to content

Commit 9822c9a

Browse files
committed
feat: add configmap-secret translation
1 parent 0a5d839 commit 9822c9a

File tree

3 files changed

+123
-135
lines changed

3 files changed

+123
-135
lines changed
Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Managing Secret using Configuration File
2+
title: Gerenciando Secret usando Arquivo de Configuração
33
content_type: task
44
weight: 20
5-
description: Creating Secret objects using resource configuration file.
5+
description: Criando objetos Secret usando arquivos de configuração de recursos.
66
---
77

88
<!-- overview -->
@@ -13,26 +13,24 @@ description: Creating Secret objects using resource configuration file.
1313

1414
<!-- steps -->
1515

16-
## Create the Config file
16+
## Crie o arquivo de configuração
1717

18-
You can create a Secret in a file first, in JSON or YAML format, and then
19-
create that object. The
20-
[Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core)
21-
resource contains two maps: `data` and `stringData`.
22-
The `data` field is used to store arbitrary data, encoded using base64. The
23-
`stringData` field is provided for convenience, and it allows you to provide
24-
Secret data as unencoded strings.
25-
The keys of `data` and `stringData` must consist of alphanumeric characters,
26-
`-`, `_` or `.`.
18+
Você pode criar um Secret primeiramente em um arquivo, no formato JSON ou YAML, e depois
19+
criar o objeto. O recurso [Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core)
20+
contém dois *maps*: `data` e `stringData`.
21+
O campo `data` é usado para armazenar dados arbitrários, codificados usando base64. O
22+
campo `stringData` é usado por conveniência, e permite que você use dados para um Secret
23+
como *strings* não codificadas.
24+
As chaves para `data` e `stringData` precisam ser compostas por caracteres alfanuméricos,
25+
`_`, `-` ou `.`.
2726

28-
For example, to store two strings in a Secret using the `data` field, convert
29-
the strings to base64 as follows:
27+
Por exemplo, para armazenar duas strings em um Secret usando o campo `data`, converta
28+
as strings para base64 da seguinte forma:
3029

3130
```shell
3231
echo -n 'admin' | base64
3332
```
34-
35-
The output is similar to:
33+
A saída deve ser similar a:
3634

3735
```
3836
YWRtaW4=
@@ -42,14 +40,13 @@ YWRtaW4=
4240
echo -n '1f2d1e2e67df' | base64
4341
```
4442

45-
The output is similar to:
43+
A saída deve ser similar a:
4644

4745
```
4846
MWYyZDFlMmU2N2Rm
4947
```
5048

51-
Write a Secret config file that looks like this:
52-
49+
Escreva o arquivo de configuração do Secret, que ser parecido com:
5350
```yaml
5451
apiVersion: v1
5552
kind: Secret
@@ -61,35 +58,34 @@ data:
6158
password: MWYyZDFlMmU2N2Rm
6259
```
6360
64-
Note that the name of a Secret object must be a valid
65-
[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
61+
Perceba que o nome do objeto Secret precisa ser um
62+
[nome de subdomínio DNS](/docs/concepts/overview/working-with-objects/names#dns-subdomain-name) válido.
6663
6764
{{< note >}}
68-
The serialized JSON and YAML values of Secret data are encoded as base64
69-
strings. Newlines are not valid within these strings and must be omitted. When
70-
using the `base64` utility on Darwin/macOS, users should avoid using the `-b`
71-
option to split long lines. Conversely, Linux users *should* add the option
72-
`-w 0` to `base64` commands or the pipeline `base64 | tr -d '\n'` if the `-w`
73-
option is not available.
65+
Os valores serializados dos dados JSON e YAML de um Secret são codificados em strings
66+
base64. Novas linhas não são válidas com essas strings e devem ser omitidas. Quando
67+
usar o utilitário `base64` em Darwin/MacOS, os usuários devem evitar usar a opção `-b`
68+
para separar linhas grandes. Por outro lado, usuários de Linux *devem* adicionar a opção
69+
`-w 0` ao comando `base64` ou o *pipe* `base64 | tr -d '\n'` se a opção `w` não for disponível
7470
{{< /note >}}
7571

76-
For certain scenarios, you may wish to use the `stringData` field instead. This
77-
field allows you to put a non-base64 encoded string directly into the Secret,
78-
and the string will be encoded for you when the Secret is created or updated.
72+
Para cenários específicos, você pode querer usar o campo `stringData` ao invés de `data`.
73+
Esse campo permite que você use strings não-base64 diretamente dentro do Secret,
74+
e a string vai ser codificada para você quando o Secret for criado ou atualizado.
7975

80-
A practical example of this might be where you are deploying an application
81-
that uses a Secret to store a configuration file, and you want to populate
82-
parts of that configuration file during your deployment process.
76+
Um exemplo prático para isso pode ser quando você esteja fazendo *deploy* de uma aplicação
77+
que usa um Secret para armazenar um arquivo de configuração, e você quer popular partes desse
78+
arquivo de configuração durante o processo de *deployment*.
8379

84-
For example, if your application uses the following configuration file:
80+
Por exemplo, se sua aplicação usa o seguinte arquivo de configuração:
8581

8682
```yaml
8783
apiUrl: "https://my.api.com/api/v1"
8884
username: "<user>"
8985
password: "<password>"
9086
```
9187

92-
You could store this in a Secret using the following definition:
88+
Você pode armazenar isso em um Secret usando a seguinte definição:
9389

9490
```yaml
9591
apiVersion: v1
@@ -104,30 +100,30 @@ stringData:
104100
password: <password>
105101
```
106102

107-
## Create the Secret object
103+
## Crie o objeto Secret
108104

109-
Now create the Secret using [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply):
105+
Agora, crie o Secret usando [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply):
110106

111107
```shell
112108
kubectl apply -f ./secret.yaml
113109
```
114110

115-
The output is similar to:
111+
A saída deve ser similar a:
116112

117113
```
118114
secret/mysecret created
119115
```
120116

121-
## Check the Secret
117+
## Verifique o Secret
122118

123-
The `stringData` field is a write-only convenience field. It is never output when
124-
retrieving Secrets. For example, if you run the following command:
119+
O campo `stringData` é um campo de conveniência apenas de leitura. Ele nunca vai ser exibido
120+
ao buscar um Secret. Por exemplo, se você executar o seguinte comando:
125121

126122
```shell
127123
kubectl get secret mysecret -o yaml
128124
```
129125

130-
The output is similar to:
126+
A saída deve ser similar a:
131127

132128
```yaml
133129
apiVersion: v1
@@ -143,14 +139,13 @@ data:
143139
config.yaml: YXBpVXJsOiAiaHR0cHM6Ly9teS5hcGkuY29tL2FwaS92MSIKdXNlcm5hbWU6IHt7dXNlcm5hbWV9fQpwYXNzd29yZDoge3twYXNzd29yZH19
144140
```
145141

146-
The commands `kubectl get` and `kubectl describe` avoid showing the contents of a `Secret` by
147-
default. This is to protect the `Secret` from being exposed accidentally to an onlooker,
148-
or from being stored in a terminal log.
149-
To check the actual content of the encoded data, please refer to
150-
[decoding secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret).
142+
Os comandos `kubectl get` e `kubectl describe` omitem o conteúdo de um `Secret` por padrão.
143+
Isso para proteger o `Secret` de ser exposto acidentalmente para uma pessoa não autorizada,
144+
ou ser armazenado em um log de terminal.
145+
Para verificar o conteúdo atual de um dado codificado, veja [decodificando secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret).
151146

152-
If a field, such as `username`, is specified in both `data` and `stringData`,
153-
the value from `stringData` is used. For example, the following Secret definition:
147+
Se um campo, como `username`, é especificado em `data` e `stringData`,
148+
o valor de `stringData` é o usado. Por exemplo, dado a seguinte definição do Secret:
154149

155150
```yaml
156151
apiVersion: v1
@@ -164,7 +159,7 @@ stringData:
164159
username: administrator
165160
```
166161

167-
Results in the following Secret:
162+
Resulta no seguinte Secret:
168163

169164
```yaml
170165
apiVersion: v1
@@ -180,19 +175,19 @@ data:
180175
username: YWRtaW5pc3RyYXRvcg==
181176
```
182177

183-
Where `YWRtaW5pc3RyYXRvcg==` decodes to `administrator`.
178+
Onde `YWRtaW5pc3RyYXRvcg==` é decodificado em `administrator`.
184179

185-
## Clean Up
180+
## Limpeza
186181

187-
To delete the Secret you have created:
182+
Para apagar o Secret que você criou:
188183

189184
```shell
190185
kubectl delete secret mysecret
191186
```
192187

193188
## {{% heading "whatsnext" %}}
194189

195-
- Read more about the [Secret concept](/docs/concepts/configuration/secret/)
196-
- Learn how to [manage Secret with the `kubectl` command](/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
197-
- Learn how to [manage Secret using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
190+
- Leia mais sobre o [conceito do Secret](/docs/concepts/configuration/secret/)
191+
- Leia sobre como [gerenciar Secret com o comando `kubectl`](/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
192+
- Leia sobre como [gerenciar Secret usando kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
198193

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Managing Secret using kubectl
2+
title: kubectl Gerenciando Secret usando kubectl
33
content_type: task
44
weight: 10
5-
description: Creating Secret objects using kubectl command line.
5+
description: Criando objetos Secret usando a linha de comando kubectl.
66
---
77

88
<!-- overview -->
@@ -13,87 +13,83 @@ description: Creating Secret objects using kubectl command line.
1313

1414
<!-- steps -->
1515

16-
## Create a Secret
16+
## Criando um Secret
1717

18-
A `Secret` can contain user credentials required by Pods to access a database.
19-
For example, a database connection string consists of a username and password.
20-
You can store the username in a file `./username.txt` and the password in a
21-
file `./password.txt` on your local machine.
18+
Um `Secret` pode conter credenciais de usuário requeridas por Pods para acesso a um banco de dados.
19+
Por exemplo, uma string de conexão de banco de dados é composta por um usuário e senha.
20+
Você pode armazenar o usuário em um arquivo `./username.txt` e a senha em um
21+
arquivo `./password.txt` na sua máquina local.
2222

2323
```shell
2424
echo -n 'admin' > ./username.txt
2525
echo -n '1f2d1e2e67df' > ./password.txt
2626
```
2727

28-
The `-n` flag in the above two commands ensures that the generated files will
29-
not contain an extra newline character at the end of the text. This is
30-
important because when `kubectl` reads a file and encode the content into
31-
base64 string, the extra newline character gets encoded too.
28+
A opção `-n` nos comandos acima garante que os arquivos criados não vão conter
29+
uma nova linha extra no final do arquivo de texto. Isso é importante porque
30+
quando o `kubectl` lê um arquivo e codifica o conteúdo em uma string base64,
31+
o caractere da nova linha extra também é codificado.
32+
33+
O comando `kubectl create secret` empacota os arquivos em um Secret e cria um
34+
objeto no API server.
3235

33-
The `kubectl create secret` command packages these files into a Secret and creates
34-
the object on the API server.
3536

3637
```shell
3738
kubectl create secret generic db-user-pass \
3839
--from-file=./username.txt \
3940
--from-file=./password.txt
4041
```
4142

42-
The output is similar to:
43+
A saída deve ser similar a:
4344

4445
```
4546
secret/db-user-pass created
4647
```
4748

48-
Default key name is the filename. You may optionally set the key name using
49-
`--from-file=[key=]source`. For example:
49+
O nome da chave padrão é o nome do arquivo. Opcionalmente, você pode definir
50+
o nome da chave usando `--from-file=[key=]source`. Por exemplo:
5051

5152
```shell
5253
kubectl create secret generic db-user-pass \
5354
--from-file=username=./username.txt \
5455
--from-file=password=./password.txt
5556
```
57+
Você não precisa escapar o caractere especial em senhas a partir de arquivos (`--from-file`).
5658

57-
You do not need to escape special characters in passwords from files
58-
(`--from-file`).
59-
60-
You can also provide Secret data using the `--from-literal=<key>=<value>` tag.
61-
This tag can be specified more than once to provide multiple key-value pairs.
62-
Note that special characters such as `$`, `\`, `*`, `=`, and `!` will be
63-
interpreted by your [shell](https://en.wikipedia.org/wiki/Shell_(computing))
64-
and require escaping.
65-
In most shells, the easiest way to escape the password is to surround it with
66-
single quotes (`'`). For example, if your actual password is `S!B\*d$zDsb=`,
67-
you should execute the command this way:
59+
Você também pode prover dados para Secret usando a tag `--from-literal=<key>=<value>`.
60+
Essa tag pode ser especificada mais de uma vez para prover múltiplos pares de chave-valor.
61+
Observe que caracteres especiais como `$`, `\`, `*`, `=`, e `!` vão ser interpretados
62+
pelo seu [shell](https://en.wikipedia.org/wiki/Shell_(computing)) e precisam ser escapados.
63+
Na maioria dos shells, a forma mais fácil de escapar as senhas é usar aspas simples (`'`).
64+
Por exemplo, se sua senha atual é `S!B\*d$zDsb=`, você precisa executar o comando dessa forma:
6865

6966
```shell
7067
kubectl create secret generic dev-db-secret \
7168
--from-literal=username=devuser \
7269
--from-literal=password='S!B\*d$zDsb='
7370
```
7471

75-
## Verify the Secret
72+
## Verificando o Secret
7673

77-
You can check that the secret was created:
74+
Você pode verificar se o secret foi criado:
7875

7976
```shell
8077
kubectl get secrets
8178
```
8279

83-
The output is similar to:
80+
A saída deve ser similar a:
8481

8582
```
8683
NAME TYPE DATA AGE
8784
db-user-pass Opaque 2 51s
8885
```
8986

90-
You can view a description of the `Secret`:
87+
Você pode ver a descrição do `Secret`:
9188

9289
```shell
9390
kubectl describe secrets/db-user-pass
9491
```
95-
96-
The output is similar to:
92+
A saída deve ser similar a:
9793

9894
```
9995
Name: db-user-pass
@@ -109,39 +105,39 @@ password: 12 bytes
109105
username: 5 bytes
110106
```
111107

112-
The commands `kubectl get` and `kubectl describe` avoid showing the contents
113-
of a `Secret` by default. This is to protect the `Secret` from being exposed
114-
accidentally to an onlooker, or from being stored in a terminal log.
108+
Os comandos `kubectl get` e `kubectl describe` omitem o conteúdo de um `Secret` por padrão.
109+
Isso para proteger o `Secret` de ser exposto acidentalmente para uma pessoa não autorizada,
110+
ou ser armazenado em um log de terminal.
115111

116-
## Decoding the Secret {#decoding-secret}
112+
## Decodificando o Secret {#decoding-secret}
117113

118-
To view the contents of the Secret you created, run the following command:
114+
Para ver o conteúdo de um Secret que você criou, execute o seguinte comando:
119115

120116
```shell
121117
kubectl get secret db-user-pass -o jsonpath='{.data}'
122118
```
123119

124-
The output is similar to:
120+
A saída deve ser similar a:
125121

126122
```json
127123
{"password":"MWYyZDFlMmU2N2Rm","username":"YWRtaW4="}
128124
```
129125

130-
Now you can decode the `password` data:
126+
Agora, você pode decodificar os dados de `password`:
131127

132128
```shell
133129
echo 'MWYyZDFlMmU2N2Rm' | base64 --decode
134130
```
135131

136-
The output is similar to:
132+
A saída deve ser similar a:
137133

138134
```
139135
1f2d1e2e67df
140136
```
141137

142-
## Clean Up
138+
## Limpeza
143139

144-
To delete the Secret you have created:
140+
Para apagar o Secret que você criou:
145141

146142
```shell
147143
kubectl delete secret db-user-pass
@@ -151,6 +147,6 @@ kubectl delete secret db-user-pass
151147

152148
## {{% heading "whatsnext" %}}
153149

154-
- Read more about the [Secret concept](/docs/concepts/configuration/secret/)
155-
- Learn how to [manage Secret using config file](/docs/tasks/configmap-secret/managing-secret-using-config-file/)
156-
- Learn how to [manage Secret using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
150+
- Leia mais sobre o [conceito do Secret](/docs/concepts/configuration/secret/)
151+
- Leia sobre como [gerenciar Secret com o comando `kubectl`](/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
152+
- Leia sobre como [gerenciar Secret usando kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)

0 commit comments

Comments
 (0)