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
858b9539
Commit
858b9539
authored
Apr 01, 2016
by
Lucas Käldström
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix so setup-files don't recreate/invalidate certificates that already exist
parent
76fde46b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
13 deletions
+37
-13
setup-files.sh
cluster/images/hyperkube/setup-files.sh
+37
-13
No files found.
cluster/images/hyperkube/setup-files.sh
View file @
858b9539
...
...
@@ -23,28 +23,52 @@ set -o errexit
set
-o
nounset
set
-o
pipefail
create_token
()
{
echo
$(
cat
/dev/urandom |
base64
|
tr
-d
"=+/"
|
dd
bs
=
32
count
=
1 2> /dev/null
)
}
# Additional address of the API server to be added to the
# list of Subject Alternative Names of the server TLS certificate
# Should contain internal IP, i.e. IP:10.0.0.1 for 10.0.0.0/24 cluster IP range
EXTRA_SANS
=
$1
create_token
()
{
echo
$(
cat
/dev/urandom |
base64
|
tr
-d
"=+/"
|
dd
bs
=
32
count
=
1 2> /dev/null
)
}
# Files in /data are persistent across reboots, so we don't want to re-create the files if they already
# exist, because the state is persistent in etcd too, and we don't want a conflict between "old" data in
# etcd and "new" data that this script would create for apiserver. Therefore, if the file exist, skip it.
if
[[
!
-f
/data/ca.crt
]]
;
then
# Create HTTPS certificates
groupadd
-f
-r
kube-cert-test
# hostname -I gets the ip of the node
CERT_DIR
=
/data
CERT_GROUP
=
kube-cert-test /make-ca-cert.sh
$(
hostname
-I
|
awk
'{print $1}'
)
${
EXTRA_SANS
}
echo
"Certificates created
$(
date
)
"
else
echo
"Certificates already found, not recreating."
fi
if
[[
!
-f
/data/basic_auth.csv
]]
;
then
# Create basic token authorization
echo
"admin,admin,admin"
>
/data/basic_auth.csv
# Create basic token authorization
echo
"admin,admin,admin"
>
/data/basic_auth.csv
echo
"basic_auth.csv created
$(
date
)
"
else
echo
"basic_auth.csv already found, not recreating."
fi
# Create HTTPS certificates
groupadd
-f
-r
kube-cert-test
if
[[
!
-f
/data/known_tokens.csv
]]
;
then
# hostname -I gets the ip of the node
CERT_DIR
=
/data
CERT_GROUP
=
kube-cert-test /make-ca-cert.sh
$(
hostname
-I
|
awk
'{print $1}'
)
${
EXTRA_SANS
}
# Create known tokens for service accounts
echo
"
$(
create_token
)
,admin,admin"
>>
/data/known_tokens.csv
echo
"
$(
create_token
)
,kubelet,kubelet"
>>
/data/known_tokens.csv
echo
"
$(
create_token
)
,kube_proxy,kube_proxy"
>>
/data/known_tokens.csv
# Create known tokens for service accounts
e
cho
"
$(
create_token
)
,admin,admin"
>>
/data/known_tokens.csv
echo
"
$(
create_token
)
,kubelet,kubelet"
>>
/data/known_tokens.csv
echo
"
$(
create_token
)
,kube_proxy,kube_proxy"
>>
/data/known_tokens.csv
echo
"known_tokens.csv created
$(
date
)
"
e
lse
echo
"known_tokens.csv already found, not recreating."
fi
while
true
;
do
sleep
3600
...
...
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