Skip to content

Commit 7cbee99

Browse files
committed
add CA data to local up generated karmada config for enhanced security
Signed-off-by: chaosi-zju <[email protected]>
1 parent f19a4b5 commit 7cbee99

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

hack/deploy-karmada.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ else
265265
fi
266266

267267
# write karmada api server config to kubeconfig file
268-
util::append_client_kubeconfig "${HOST_CLUSTER_KUBECONFIG}" "${CERT_DIR}/client.crt" "${CERT_DIR}/client.key" "${KARMADA_APISERVER_IP}" "${KARMADA_APISERVER_SECURE_PORT}" karmada-apiserver
268+
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
269269

270270
# deploy kube controller manager
271271
cp "${REPO_ROOT}"/artifacts/deploy/kube-controller-manager.yaml "${TEMP_PATH_APISERVER}"/kube-controller-manager.yaml

hack/util.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,14 @@ EOF
258258
# util::append_client_kubeconfig creates a new context including a cluster and a user to the existed kubeconfig file
259259
function util::append_client_kubeconfig {
260260
local kubeconfig_path=$1
261-
local client_certificate_file=$2
262-
local client_key_file=$3
263-
local api_host=$4
264-
local api_port=$5
265-
local client_id=$6
266-
local token=${7:-}
267-
kubectl config set-cluster "${client_id}" --server=https://"${api_host}:${api_port}" --insecure-skip-tls-verify=true --kubeconfig="${kubeconfig_path}"
261+
local ca_file=$2
262+
local client_certificate_file=$3
263+
local client_key_file=$4
264+
local api_host=$5
265+
local api_port=$6
266+
local client_id=$7
267+
local token=${8:-}
268+
kubectl config set-cluster "${client_id}" --server=https://"${api_host}:${api_port}" --embed-certs --certificate-authority="${ca_file}" --kubeconfig="${kubeconfig_path}"
268269
kubectl config set-credentials "${client_id}" --token="${token}" --client-certificate="${client_certificate_file}" --client-key="${client_key_file}" --embed-certs=true --kubeconfig="${kubeconfig_path}"
269270
kubectl config set-context "${client_id}" --cluster="${client_id}" --user="${client_id}" --kubeconfig="${kubeconfig_path}"
270271
}

0 commit comments

Comments
 (0)