-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add certificate based authentication to localkube/minikube. #48
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
13e5937
Add code to setup authentication on the remote cluster.
d4227ab
Add a flag for controlling the localkube binary location.
dlorenc d59e054
Move script to it's own file.
dlorenc 4f712bf
Make localkube serve securely.
dlorenc 23d906b
Remove weave.
dlorenc 716cc2e
Fix tests.
dlorenc e5d9602
Add --containerized flag.
dlorenc 70ab8a0
Make string formatting explicit.
dlorenc 182601a
Fix formatting of instructions.
dlorenc 5a8e107
Make the localkube download support compression.
dlorenc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cluster | ||
|
||
var startCommand = ` | ||
sudo killall localkube || true | ||
# Download and install localkube, if it doesn't exist yet. | ||
if [ ! -e /usr/local/bin/localkube ]; then | ||
sudo curl -L %s -o /usr/local/bin/localkube | ||
sudo chmod a+x /usr/local/bin/localkube; | ||
fi | ||
# Fetch easy-rsa. | ||
sudo mkdir -p /srv/kubernetes/certs && sudo chmod -R 777 /srv | ||
if [ ! -e easy-rsa.tar.gz ]; then | ||
curl -L -O https://storage.googleapis.com/kubernetes-release/easy-rsa/easy-rsa.tar.gz | ||
fi | ||
rm -rf easy-rsa-master | ||
tar xzf easy-rsa.tar.gz | ||
# Create certs. | ||
cert_ip=$(ip addr show ${interface} | grep 192.168 | sed -nEe 's/^[ \t]*inet[ \t]*([0-9.]+)\/.*$/\1/p') | ||
ts=$(date +%%s) | ||
if ! grep $cert_ip /srv/kubernetes/certs/kubernetes-master.crt; then | ||
cd easy-rsa-master/easyrsa3 | ||
./easyrsa init-pki | ||
./easyrsa --batch "--req-cn=$cert_ip@$ts" build-ca nopass | ||
./easyrsa --subject-alt-name="IP:$cert_ip" build-server-full kubernetes-master nopass | ||
./easyrsa build-client-full kubecfg nopass | ||
cp -p pki/ca.crt /srv/kubernetes/certs/ | ||
cp -p pki/issued/kubecfg.crt /srv/kubernetes/certs/ | ||
cp -p pki/private/kubecfg.key /srv/kubernetes/certs/ | ||
cp -p pki/issued/kubernetes-master.crt /srv/kubernetes/certs/ | ||
cp -p pki/private/kubernetes-master.key /srv/kubernetes/certs/ | ||
fi | ||
# Run with nohup so it stays up. Redirect logs to useful places. | ||
PATH=/usr/local/sbin:$PATH nohup sudo /usr/local/bin/localkube --containerized=false start > /var/log/localkube.out 2> /var/log/localkube.err < /dev/null & | ||
` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about creating the certs with go instead?
Maybe that's easier...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a few different ways, using https://github.com/SvenDowideit/generate_cert/blob/master/generate_cert.go but was unable to get anything working in pure go :(