Skip to content

Commit

Permalink
Merge pull request #5739 from chaosi-zju/local-up-ca
Browse files Browse the repository at this point in the history
add CA data to local up generated karmada config for enhanced security
  • Loading branch information
karmada-bot authored Oct 24, 2024
2 parents 7347f11 + 7cbee99 commit 5e7d836
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hack/deploy-karmada.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ else
fi

# write karmada api server config to kubeconfig file
util::append_client_kubeconfig "${HOST_CLUSTER_KUBECONFIG}" "${CERT_DIR}/client.crt" "${CERT_DIR}/client.key" "${KARMADA_APISERVER_IP}" "${KARMADA_APISERVER_SECURE_PORT}" karmada-apiserver
util::append_client_kubeconfig "${HOST_CLUSTER_KUBECONFIG}" "${ROOT_CA_FILE}" "${CERT_DIR}/client.crt" "${CERT_DIR}/client.key" "${KARMADA_APISERVER_IP}" "${KARMADA_APISERVER_SECURE_PORT}" karmada-apiserver

# deploy kube controller manager
cp "${REPO_ROOT}"/artifacts/deploy/kube-controller-manager.yaml "${TEMP_PATH_APISERVER}"/kube-controller-manager.yaml
Expand Down
15 changes: 8 additions & 7 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,14 @@ EOF
# util::append_client_kubeconfig creates a new context including a cluster and a user to the existed kubeconfig file
function util::append_client_kubeconfig {
local kubeconfig_path=$1
local client_certificate_file=$2
local client_key_file=$3
local api_host=$4
local api_port=$5
local client_id=$6
local token=${7:-}
kubectl config set-cluster "${client_id}" --server=https://"${api_host}:${api_port}" --insecure-skip-tls-verify=true --kubeconfig="${kubeconfig_path}"
local ca_file=$2
local client_certificate_file=$3
local client_key_file=$4
local api_host=$5
local api_port=$6
local client_id=$7
local token=${8:-}
kubectl config set-cluster "${client_id}" --server=https://"${api_host}:${api_port}" --embed-certs --certificate-authority="${ca_file}" --kubeconfig="${kubeconfig_path}"
kubectl config set-credentials "${client_id}" --token="${token}" --client-certificate="${client_certificate_file}" --client-key="${client_key_file}" --embed-certs=true --kubeconfig="${kubeconfig_path}"
kubectl config set-context "${client_id}" --cluster="${client_id}" --user="${client_id}" --kubeconfig="${kubeconfig_path}"
}
Expand Down

0 comments on commit 5e7d836

Please sign in to comment.