Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ad9fa30e
Commit
ad9fa30e
authored
Feb 04, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20023 from erictune/secrets-doc
Auto commit by PR queue bot
parents
59820827
db574600
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
25 deletions
+27
-25
images.md
docs/user-guide/images.md
+27
-25
secrets.md
docs/user-guide/secrets.md
+0
-0
No files found.
docs/user-guide/images.md
View file @
ad9fa30e
...
@@ -51,6 +51,9 @@ The `image` property of a container supports the same syntax as the `docker` com
...
@@ -51,6 +51,9 @@ The `image` property of a container supports the same syntax as the `docker` com
-
[
Configuring Nodes to Authenticate to a Private Repository
](
#configuring-nodes-to-authenticate-to-a-private-repository
)
-
[
Configuring Nodes to Authenticate to a Private Repository
](
#configuring-nodes-to-authenticate-to-a-private-repository
)
-
[
Pre-pulling Images
](
#pre-pulling-images
)
-
[
Pre-pulling Images
](
#pre-pulling-images
)
-
[
Specifying ImagePullSecrets on a Pod
](
#specifying-imagepullsecrets-on-a-pod
)
-
[
Specifying ImagePullSecrets on a Pod
](
#specifying-imagepullsecrets-on-a-pod
)
-
[
Creating a Secret with a Docker Config
](
#creating-a-secret-with-a-docker-config
)
-
[
Bypassing kubectl create secrets
](
#bypassing-kubectl-create-secrets
)
-
[
Referring to an imagePullSecrets on a Pod
](
#referring-to-an-imagepullsecrets-on-a-pod
)
-
[
Use Cases
](
#use-cases
)
-
[
Use Cases
](
#use-cases
)
<!-- END MUNGE: GENERATED_TOC -->
<!-- END MUNGE: GENERATED_TOC -->
...
@@ -207,42 +210,40 @@ where node creation is automated.
...
@@ -207,42 +210,40 @@ where node creation is automated.
Kubernetes supports specifying registry keys on a pod.
Kubernetes supports specifying registry keys on a pod.
First, create a
`.docker/config.json`
, such as by running
`docker login <registry.domain>`
.
#### Creating a Secret with a Docker Config
Then put the resulting
`.docker/config.json`
file into a
[
secret resource
](
secrets.md
)
. For example:
Run the following command, substituting the appropriate uppercase values:
```
console
```
console
$
docker login
$
kubectl create secret docker-registry my-registry-secret
--docker-server
=
DOCKER_REGISTRY_SERVER
--docker-username
=
DOCKER_USER
--docker-password
=
DOCKER_PASSWORD
--docker-email
=
DOCKER_EMAIL
Username: janedoe
secret "my-registry-secret" created.
Password: ●●●●●●●●●●●
```
Email: jdoe@example.com
WARNING: login credentials saved in /Users/jdoe/.docker/config.json.
Login Succeeded
$
echo
$(
cat
~/.docker/config.json
)
If you need access to multiple registries, you can create one secret for each registry.
{ "https://index.docker.io/v1/": { "auth": "ZmFrZXBhc3N3b3JkMTIK", "email": "jdoe@example.com" } }
Kubelet will merge any
`imagePullSecrets`
into a single virtual
`.docker/config.json`
when pulling images for your Pods.
$
cat
~/.docker/config.json |
base64
Pods can only reference image pull secrets in their own namespace,
eyAiaHR0cHM6Ly9pbmRleC5kb2NrZXIuaW8vdjEvIjogeyAiYXV0aCI6ICJabUZyWlhCaGMzTjNiM0prTVRJSyIsICJlbWFpbCI6ICJqZG9lQGV4YW1wbGUuY29tIiB9IH0K
so this process needs to be done one time per namespace.
$
cat
>
/tmp/image-pull-secret.yaml
<<
EOF
##### Bypassing kubectl create secrets
apiVersion: v1
kind: Secret
metadata:
name: myregistrykey
data:
.dockerconfigjson: eyAiaHR0cHM6Ly9pbmRleC5kb2NrZXIuaW8vdjEvIjogeyAiYXV0aCI6ICJabUZyWlhCaGMzTjNiM0prTVRJSyIsICJlbWFpbCI6ICJqZG9lQGV4YW1wbGUuY29tIiB9IH0K
type: kubernetes.io/dockerconfigjson
EOF
$
kubectl create
-f
/tmp/image-pull-secret.yaml
If for some reason you need multiple items in a single
`.docker/config.json`
or need
secrets/myregistrykey
control not given by the above command, then you can
[
create a secret using
```
json or yaml](secrets.md#creating-a-secret-manually).
Be sure to:
-
set the name of the data item to
`.dockerconfigjson`
-
base64 encode the docker file and paste that string, unbroken
as the value for field
`data[".dockerconfigjson"]`
-
set
`type`
to
`kubernetes.io/dockerconfigjson`
If you get the error message
`error: no objects passed to create`
, it may mean the base64 encoded string is invalid.
If you get the error message
`error: no objects passed to create`
, it may mean the base64 encoded string is invalid.
If you get an error message like
`Secret "myregistrykey" is invalid: data[.dockerconfigjson]: invalid value ...`
it means
If you get an error message like
`Secret "myregistrykey" is invalid: data[.dockerconfigjson]: invalid value ...`
it means
the data was successfully un-base64 encoded, but could not be parsed as a
`.docker/config.json`
file.
the data was successfully un-base64 encoded, but could not be parsed as a
`.docker/config.json`
file.
This process needs to be done one time per namespace, or to any non-default service accounts you create.
#### Referring to an imagePullSecrets on a Pod
Now, you can create pods which reference that secret by adding an
`imagePullSecrets`
Now, you can create pods which reference that secret by adding an
`imagePullSecrets`
section to a pod definition.
section to a pod definition.
...
@@ -261,6 +262,7 @@ spec:
...
@@ -261,6 +262,7 @@ spec:
```
```
This needs to be done for each pod that is using a private registry.
This needs to be done for each pod that is using a private registry.
However, setting of this field can be automated by setting the imagePullSecrets
However, setting of this field can be automated by setting the imagePullSecrets
in a
[
serviceAccount
](
service-accounts.md
)
resource.
in a
[
serviceAccount
](
service-accounts.md
)
resource.
...
...
docs/user-guide/secrets.md
View file @
ad9fa30e
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment