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
e1885ba0
Commit
e1885ba0
authored
Apr 29, 2015
by
Paul Morie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add example for secrets
parent
ad37263a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
0 deletions
+71
-0
README.md
examples/secrets/README.md
+46
-0
secret-pod.yaml
examples/secrets/secret-pod.yaml
+18
-0
secret.yaml
examples/secrets/secret.yaml
+7
-0
No files found.
examples/secrets/README.md
0 → 100644
View file @
e1885ba0
# Secrets example
Following this example, you will create a secret and a pod that consumes that secret in a volume.
## Step Zero: Prerequisites
This example assumes you have a Kubernetes cluster installed and running, and that you have
installed the
```kubectl```
command line tool somewhere in your path. Please see the
[
getting
started](../../docs/getting-started-guides) for installation instructions for your platform.
## Step One: Create the secret
A secret contains a set of named byte arrays.
Use the
`examples/secrets/secret.yaml`
file to create a secret:
```
shell
$
kubectl create
-f
examples/secrets/secret.yaml
```
You can use
`kubectl`
to see information about the secret:
```
shell
$
kubectl get secrets
NAME TYPE DATA
test-secret Opaque 2
```
## Step Two: Create a pod that consumes a secret
Pods consume secrets in volumes. Now that you have created a secret, you can create a pod that
consumes it.
Use the
`examples/secrets/secret-pod.yaml`
file to create a Pod that consumes the secret.
```
shell
$
kubectl create
-f
examples/secrets/secret-pod.yaml
```
This pod runs a binary that displays the content of one of the pieces of secret data in the secret
volume:
```
shell
$
kubectl log secret-test-pod
2015-04-29T21:17:24.712206409Z content of file
"/etc/secret-volume/data-1"
: value-1
```
examples/secrets/secret-pod.yaml
0 → 100644
View file @
e1885ba0
apiVersion
:
v1beta3
kind
:
Pod
metadata
:
name
:
secret-test-pod
spec
:
containers
:
-
name
:
test-container
image
:
kubernetes/mounttest:0.1
command
:
[
"
/mt"
,
"
--file_content=/etc/secret-volume/data-1"
]
volumeMounts
:
# name must match the volume name below
-
name
:
secret-volume
mountPath
:
/etc/secret-volume
volumes
:
-
name
:
secret-volume
secret
:
secretName
:
test-secret
restartPolicy
:
Never
examples/secrets/secret.yaml
0 → 100644
View file @
e1885ba0
apiVersion
:
v1beta3
kind
:
Secret
metadata
:
name
:
test-secret
data
:
data-1
:
dmFsdWUtMQ0K
data-2
:
dmFsdWUtMg0KDQo=
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