Replace clusterIP with hostNetwork when using remote-up-karmada.sh
Signed-off-by: lonelyCZ <531187475@qq.com>
This commit is contained in:
parent
13e01fef6b
commit
5b5fc08005
|
@ -19,24 +19,21 @@ your clusters based on the codebase.
|
||||||
|
|
||||||
The `hack/remote-up-karmada.sh` will install `karmada-apiserver` and provide two ways to expose the server:
|
The `hack/remote-up-karmada.sh` will install `karmada-apiserver` and provide two ways to expose the server:
|
||||||
|
|
||||||
### 1. expose by service with `LoadBalancer` type
|
### 1. expose by `HostNetwork` type
|
||||||
|
|
||||||
By default, the `hack/remote-up-karmada.sh` will expose `karmada-apiserver` by a service with `LoadBalancer`
|
By default, the `hack/remote-up-karmada.sh` will expose `karmada-apiserver` by `HostNetwork`.
|
||||||
type, and continue the installation progress after the `Load Balancer` allocates an external IP for the
|
|
||||||
`karmada-apiserver`.
|
|
||||||
|
|
||||||
No extra operations needed with this type, but that *requires your cluster have deployed the `Load Balancer`*.
|
No extra operations needed with this type.
|
||||||
|
|
||||||
### 2. expose by service with `ClusterIP` type
|
### 2. expose by service with `LoadBalancer` type
|
||||||
If you don't want to use the `Load Balancer`, you can ask `hack/remote-up-karmada.sh` to expose `karmada-apiserver`
|
|
||||||
by a service with `ClusterIP` type. All you need to do is set an environment:
|
If you don't want to use the `HostNetwork`, you can ask `hack/remote-up-karmada.sh` to expose `karmada-apiserver`
|
||||||
|
by a service with `LoadBalancer` type that *requires your cluster have deployed the `Load Balancer`*.
|
||||||
|
All you need to do is set an environment:
|
||||||
```bash
|
```bash
|
||||||
export CLUSTER_IP_ONLY=true
|
export LOAD_BALANCER=true
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: You should run `hack/remote-up-karmada.sh` on one of the nodes of the cluster, otherwise the `hack/remote-up-karmada.sh`
|
|
||||||
> can't access the `karmada-apiserver` exposed by a `cluster IP`.
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
From the `root` directory the `karmada` repo, install Karmada by command:
|
From the `root` directory the `karmada` repo, install Karmada by command:
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -14,7 +14,7 @@ ensures development quality.
|
||||||
|
|
||||||
- [`remote-up-karmada.sh`](remote-up-karmada.sh) This script will install Karmada to a standalone K8s cluster, this cluster
|
- [`remote-up-karmada.sh`](remote-up-karmada.sh) This script will install Karmada to a standalone K8s cluster, this cluster
|
||||||
may be real, remote , and even for production. It is worth noting for the connectivity from your client to Karmada API server,
|
may be real, remote , and even for production. It is worth noting for the connectivity from your client to Karmada API server,
|
||||||
it will create a load balancer service with an external IP by default, else type `export CLUSTER_IP_ONLY=true` with the `ClusterIP` type service before the following script.
|
it will directly use host network by default, else `export LOAD_BALANCER=true` with the `LoadBalancer` type service before the following script.
|
||||||
If your want to customize a load balancer service, you may add the annotations at the metadata part of service `karmada-apiserver` in
|
If your want to customize a load balancer service, you may add the annotations at the metadata part of service `karmada-apiserver` in
|
||||||
[`../artifacts/deploy/karmada-apiserver.yaml`](../artifacts/deploy/karmada-apiserver.yaml) before the installing. The
|
[`../artifacts/deploy/karmada-apiserver.yaml`](../artifacts/deploy/karmada-apiserver.yaml) before the installing. The
|
||||||
following is an example.
|
following is an example.
|
||||||
|
|
|
@ -16,7 +16,7 @@ KARMADA_APISERVER_SECURE_PORT=${KARMADA_APISERVER_SECURE_PORT:-5443}
|
||||||
HOST_CLUSTER_NAME=${HOST_CLUSTER_NAME:-"karmada-host"}
|
HOST_CLUSTER_NAME=${HOST_CLUSTER_NAME:-"karmada-host"}
|
||||||
ROOT_CA_FILE=${CERT_DIR}/server-ca.crt
|
ROOT_CA_FILE=${CERT_DIR}/server-ca.crt
|
||||||
CFSSL_VERSION="v1.5.0"
|
CFSSL_VERSION="v1.5.0"
|
||||||
CLUSTER_IP_ONLY=${CLUSTER_IP_ONLY:-false} # whether create a 'ClusterIP' type service for karmada apiserver
|
LOAD_BALANCER=${LOAD_BALANCER:-false} # whether create a 'LoadBalancer' type service for karmada apiserver
|
||||||
source "${REPO_ROOT}"/hack/util.sh
|
source "${REPO_ROOT}"/hack/util.sh
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
|
@ -145,15 +145,15 @@ util::wait_pod_ready "${ETCD_POD_LABEL}" "${KARMADA_SYSTEM_NAMESPACE}"
|
||||||
|
|
||||||
#KARMADA_APISERVER_SERVICE_TYPE is the service type of karmada API Server, For connectivity, it will be different when
|
#KARMADA_APISERVER_SERVICE_TYPE is the service type of karmada API Server, For connectivity, it will be different when
|
||||||
# HOST_CLUSTER_TYPE is different. When HOST_CLUSTER_TYPE=local, we will create a ClusterIP type Service. And when
|
# HOST_CLUSTER_TYPE is different. When HOST_CLUSTER_TYPE=local, we will create a ClusterIP type Service. And when
|
||||||
# HOST_CLUSTER_TYPE=remote, we need to create a LoadBalancer service to access Karmada API Server outside the
|
# HOST_CLUSTER_TYPE=remote, we directly use hostNetwork to access Karmada API Server outside the
|
||||||
# karmada-host cluster. Of course, you can still use a ClusterIP type Service by setting $CLUSTER_IP_ONLY=true
|
# karmada-host cluster. Of course, you can create a LoadBalancer service by setting $LOAD_BALANCER=true
|
||||||
KARMADA_APISERVER_SERVICE_TYPE="ClusterIP"
|
KARMADA_APISERVER_SERVICE_TYPE="ClusterIP"
|
||||||
|
|
||||||
if [ "${HOST_CLUSTER_TYPE}" = "local" ]; then # local mode
|
if [ "${HOST_CLUSTER_TYPE}" = "local" ]; then # local mode
|
||||||
KARMADA_APISERVER_IP=$(util::get_apiserver_ip_from_kubeconfig "${HOST_CLUSTER_NAME}")
|
KARMADA_APISERVER_IP=$(util::get_apiserver_ip_from_kubeconfig "${HOST_CLUSTER_NAME}")
|
||||||
else # remote mode
|
else # remote mode
|
||||||
# KARMADA_APISERVER_IP will be got when Karmada API Server is ready
|
# KARMADA_APISERVER_IP will be got when Karmada API Server is ready
|
||||||
if [ "${CLUSTER_IP_ONLY}" = false ]; then
|
if [ "${LOAD_BALANCER}" = true ]; then
|
||||||
KARMADA_APISERVER_SERVICE_TYPE="LoadBalancer"
|
KARMADA_APISERVER_SERVICE_TYPE="LoadBalancer"
|
||||||
fi
|
fi
|
||||||
HOST_CLUSTER_TYPE="remote" # make sure HOST_CLUSTER_TYPE is in local and remote
|
HOST_CLUSTER_TYPE="remote" # make sure HOST_CLUSTER_TYPE is in local and remote
|
||||||
|
@ -173,7 +173,7 @@ util::wait_pod_ready "${APISERVER_POD_LABEL}" "${KARMADA_SYSTEM_NAMESPACE}"
|
||||||
if [ "${HOST_CLUSTER_TYPE}" = "remote" ]; then
|
if [ "${HOST_CLUSTER_TYPE}" = "remote" ]; then
|
||||||
case $KARMADA_APISERVER_SERVICE_TYPE in
|
case $KARMADA_APISERVER_SERVICE_TYPE in
|
||||||
ClusterIP)
|
ClusterIP)
|
||||||
KARMADA_APISERVER_IP=$(kubectl get service karmada-apiserver -n "${KARMADA_SYSTEM_NAMESPACE}" -o=jsonpath='{.spec.clusterIP}')
|
KARMADA_APISERVER_IP=$(kubectl get pod -l app=karmada-apiserver -n "${KARMADA_SYSTEM_NAMESPACE}" -o=jsonpath='{.items[0].status.podIP}')
|
||||||
;;
|
;;
|
||||||
LoadBalancer)
|
LoadBalancer)
|
||||||
if util::wait_service_external_ip "karmada-apiserver" "${KARMADA_SYSTEM_NAMESPACE}"; then
|
if util::wait_service_external_ip "karmada-apiserver" "${KARMADA_SYSTEM_NAMESPACE}"; then
|
||||||
|
|
|
@ -6,13 +6,13 @@ set -o pipefail
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "This script will deploy karmada control plane to a given cluster."
|
echo "This script will deploy karmada control plane to a given cluster."
|
||||||
echo "Usage: hack/remote-up-karmada.sh <KUBECONFIG> <CONTEXT_NAME> [CLUSTER_IP_ONLY]"
|
echo "Usage: hack/remote-up-karmada.sh <KUBECONFIG> <CONTEXT_NAME> [LOAD_BALANCER]"
|
||||||
echo "Example: hack/remote-up-karmada.sh ~/.kube/config karmada-host"
|
echo "Example: hack/remote-up-karmada.sh ~/.kube/config karmada-host"
|
||||||
echo -e "Parameters:\n\tKUBECONFIG\tYour cluster's kubeconfig that you want to install to"
|
echo -e "Parameters:\n\tKUBECONFIG\tYour cluster's kubeconfig that you want to install to"
|
||||||
echo -e "\tCONTEXT_NAME\tThe name of context in 'kubeconfig'"
|
echo -e "\tCONTEXT_NAME\tThe name of context in 'kubeconfig'"
|
||||||
echo -e "\tCLUSTER_IP_ONLY\tThis option default is 'false', and there will create a 'LoadBalancer' type service
|
echo -e "\tLOAD_BALANCER\tThis option default is 'false', and there will directly use 'hostNetwork' to communicate
|
||||||
\t\t\tfor karmada apiserver so that it can easy communicate outside the karmada-host cluster,
|
\t\t\toutside the karmada-host cluster
|
||||||
\t\t\tif you want only a 'ClusterIP' type service for karmada apiserver, set as 'true'."
|
\t\t\tif you want to create a 'LoadBalancer' type service for karmada apiserver, set as 'true'."
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -lt 2 ]]; then
|
if [[ $# -lt 2 ]]; then
|
||||||
|
@ -39,8 +39,8 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${3:-false}" = true ]; then
|
if [ "${3:-false}" = true ]; then
|
||||||
CLUSTER_IP_ONLY=true
|
LOAD_BALANCER=true
|
||||||
export CLUSTER_IP_ONLY
|
export LOAD_BALANCER
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# deploy karmada control plane
|
# deploy karmada control plane
|
||||||
|
|
Loading…
Reference in New Issue