Skip to content
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

Fix vagrant cluster/kube-up #4468

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions cluster/kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ if [[ "$KUBERNETES_PROVIDER" == "gke" ]]; then
"--cluster=${CLUSTER_NAME}"
)
elif [[ "$KUBERNETES_PROVIDER" == "vagrant" ]]; then
# When we are using vagrant it has hard coded auth. We repeat that here so that
# we don't clobber auth that might be used for a publicly facing cluster.
# When we are using vagrant it has hard coded kubeconfig, and do not clobber public endpoints
config=(
"--auth-path=$HOME/.kubernetes_vagrant_auth"
)
"--kubeconfig=$HOME/.kubernetes_vagrant_kubeconfig"
)
fi

echo "current-context: \"$(${kubectl} config view -o template --template='{{index . "current-context"}}')\"" >&2
echo "current-context: \"$(${kubectl} "${config[@]:+${config[@]}}" config view -o template --template='{{index . "current-context"}}')\"" >&2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add another echo to give a copy/paste command for setting $KUBECONFIG for debugging?

echo "[INFO] To debug: export KUBECONFIG=$HOME/.kubernetes_vagrant_kubeconfig"


echo "Running:" "${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}" >&2
"${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}"
23 changes: 22 additions & 1 deletion cluster/vagrant/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function verify-cluster {
local count="0"
until [[ "$count" == "1" ]]; do
local minions
minions=$("${KUBE_ROOT}/cluster/kubectl.sh" get minions -o template -t '{{range.items}}{{.id}}:{{end}}')
minions=$("${KUBE_ROOT}/cluster/kubectl.sh --kubeconfig=${HOME}/.kubernetes_vagrant_kubeconfig" get minions -o template -t '{{range.items}}{{.id}}:{{end}}')
count=$(echo $minions | grep -c "${MINION_IPS[i]}") || {
printf "."
sleep 2
Expand Down Expand Up @@ -210,6 +210,27 @@ function kube-up {
}
EOF

cat <<EOF >"${HOME}/.kubernetes_vagrant_kubeconfig"
apiVersion: v1
clusters:
- cluster:
server: https://${MASTER_IP}:443
name: vagrant
contexts:
- context:
cluster: vagrant
namespace: default
user: vagrant
name: vagrant
current-context: "vagrant"
kind: Config
preferences: {}
users:
- name: vagrant
user:
auth-path: ${HOME}/.kubernetes_vagrant_auth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include the auth information directly into the kubeconfig file instead of referencing auth-path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can tweak that in a follow-on PR.

EOF

chmod 0600 ~/.kubernetes_vagrant_auth "${HOME}/${kube_cert}" \
"${HOME}/${kube_key}" "${HOME}/${ca_cert}"
)
Expand Down