Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
refactor: Align local-setup and quick-start deployment paths
Browse files Browse the repository at this point in the history
Updates local-setup to use the same kustomizations as the quick start
scripts. Installation and configuration of hub and spoke dependencies is
now consistent across both deployment paths.

The only difference between quick start and local setup now is that
metrics is enabled by default with local-setup and managedzones and dns
providers are created using local environment files instead of
environment variables.
  • Loading branch information
mikenairn committed Feb 22, 2024
1 parent 9b77983 commit 972f32b
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 277 deletions.
29 changes: 1 addition & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ Key Features:
- Health checks to detect and take remedial action against unhealthy endpoints
- Cloud DNS provider integrations (AWS route 53) with new ones being added (google DNS)


When deploying the multicluster gateway controller using the make targets, the following will be created:
* Kind cluster(s)
* Gateway API CRDs in the control plane cluster
* Ingress controller
* Cert manager
* ArgoCD instance
* K8s Dashboard
* LetsEncrypt certs



## Prerequisites:
* AWS or GCP
Expand Down Expand Up @@ -71,28 +66,7 @@ When deploying the multicluster gateway controller using the make targets, the f
make build-gateway-controller run-gateway-controller
```

## 3. Running the agent in the cluster:
1. Build the agent image and load it into the workload cluster
```sh
kubectl config use-context kind-mgc-workload-1
make kind-load-agent
```

1. Deploy the agent to the workload cluster
```sh
make deploy-agent
```

## 4. Running the agent locally
1. Target the workload cluster you wish to run on:
```sh
export KUBECONFIG=./tmp/kubeconfigs/mgc-workload-1.kubeconfig
```
1. Run the agent locally:
```sh
make build-agent run-agent
```
## 5. Clean up local environment
## 3. Clean up local environment
In any terminal window target control plane cluster by:
```bash
kubectl config use-context kind-mgc-control-plane
Expand Down Expand Up @@ -121,4 +95,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

6 changes: 0 additions & 6 deletions config/local-setup/issuer/issuer.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions config/local-setup/issuer/kustomization.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion config/quick-start/control-cluster/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ patchesStrategicMerge:
metadata:
name: mgc-cert-manager-webhook
namespace: cert-manager
$patch: delete
$patch: delete
201 changes: 11 additions & 190 deletions hack/.deployUtils
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ deployOCMHub(){
echo "PATCHING CLUSTERMANAGER: placement image patch to use amd64 image - See https://kubernetes.slack.com/archives/C01GE7YSUUF/p1685016272443249"
kubectl patch clustermanager cluster-manager --type='merge' -p '{"spec":{"placementImagePullSpec":"quay.io/open-cluster-management/placement:v0.11.0-amd64"}}' --context kind-${clusterName}
echo "checking if cluster is single or multi"
if [[ -n "${OCM_SINGLE}" ]]; then
deployOCMSpoke ${clusterName}
deployOLM ${KIND_CLUSTER_CONTROL_PLANE}
fi
}

deployOCMSpoke() {
Expand All @@ -84,25 +80,8 @@ deployOCMSpoke() {
done
}



# local-setup-mgc specific functions
LOCAL_SETUP_DIR="$(dirname "${BASH_SOURCE[0]}")"


deployMetalLB () {
local METALLB_KUSTOMIZATION_DIR=${LOCAL_SETUP_DIR}/../config/metallb
clusterName=${1}
metalLBSubnet=${2}

kubectl config use-context kind-${clusterName}
echo "Deploying MetalLB to ${clusterName}"
${KUSTOMIZE_BIN} build ${METALLB_KUSTOMIZATION_DIR} | kubectl apply -f -
echo "Waiting for deployments to be ready ..."
kubectl -n metallb-system wait --for=condition=ready pod --selector=app=metallb --timeout=600s
configureMetalLB ${clusterName} ${metalLBSubnet}
}

deployIngressController () {
local INGRESS_NGINX_KUSTOMIZATION_DIR="$2"
if [ -z "$2" ]; then
Expand All @@ -116,58 +95,6 @@ deployIngressController () {
kubectl -n ingress-nginx wait --timeout=600s --for=condition=Available deployments --all
}

deployCertManager() {
local CERT_MANAGER_KUSTOMIZATION_DIR=${LOCAL_SETUP_DIR}/../config/cert-manager
clusterName=${1}
echo "Deploying Cert Manager to (${clusterName})"

kubectl config use-context kind-${clusterName}

${KUSTOMIZE_BIN} build ${CERT_MANAGER_KUSTOMIZATION_DIR} --enable-helm --helm-command ${HELM_BIN} | kubectl apply -f -
echo "Waiting for Cert Manager deployments to be ready..."
kubectl -n cert-manager wait --timeout=300s --for=condition=Available deployments --all

kubectl delete validatingWebhookConfiguration mgc-cert-manager-webhook
kubectl delete mutatingWebhookConfiguration mgc-cert-manager-webhook
}

#ToDo Use kuadrant operator dependencies
deployIstio() {
local ISTIO_KUSTOMIZATION_DIR=${LOCAL_SETUP_DIR}/../config/istio/istio-operator.yaml
clusterName=${1}
echo "Deploying Istio to (${clusterName})"

kubectl config use-context kind-${clusterName}
${ISTIOCTL_BIN} operator init
kubectl apply -f ${ISTIO_KUSTOMIZATION_DIR}
}

#ToDo Use kuadrant operator dependencies
installGatewayAPI() {
local GATEWAY_API_KUSTOMIZATION_DIR=${LOCAL_SETUP_DIR}/../config/gateway-api
clusterName=${1}
kubectl config use-context kind-${clusterName}
echo "Installing Gateway API in ${clusterName}"

${KUSTOMIZE_BIN} build ${GATEWAY_API_KUSTOMIZATION_DIR} | kubectl apply -f -
}

initController() {
clusterName=${1}
kubectl config use-context kind-${clusterName}
echo "Initialize local dev setup for the controller on ${clusterName}"
# # Add the mgc CRDs
${KUSTOMIZE_BIN} build config/local-setup/controller/ | kubectl apply -f -
${KUSTOMIZE_BIN} build config/local-setup/issuer/ | kubectl apply -f -
${KUSTOMIZE_BIN} build config/dependencies/kuadrant-operator/ | kubectl apply -f -
if [[ -f "controller-config.env" && -f "gcp-credentials.env" ]]; then
${KUSTOMIZE_BIN} --reorder none --load-restrictor LoadRestrictionsNone build config/local-setup/controller/gcp | kubectl apply -f -
fi
if [[ -f "controller-config.env" && -f "aws-credentials.env" ]]; then
${KUSTOMIZE_BIN} --reorder none --load-restrictor LoadRestrictionsNone build config/local-setup/controller/aws | kubectl apply -f -
fi
}

deployThanos() {
local THANOS_KUSTOMIZATION_DIR="$2"
if [ -z "$2" ]; then
Expand Down Expand Up @@ -206,138 +133,32 @@ deployPrometheusForFederation() {
fi
}

# quickstart-setup specific functions

setupAWSProvider() {
local namespace="$1"
if [ -z "$1" ]; then
namespace="multi-cluster-gateways"
fi
if [ "$KUADRANT_AWS_ACCESS_KEY_ID" == "" ]; then
echo "KUADRANT_AWS_ACCESS_KEY_ID is not set"
exit 1
fi

kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: ${KIND_CLUSTER_PREFIX}aws-credentials
namespace: ${namespace}
type: "kuadrant.io/aws"
stringData:
AWS_ACCESS_KEY_ID: ${KUADRANT_AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${KUADRANT_AWS_SECRET_ACCESS_KEY}
AWS_REGION: ${KUADRANT_AWS_REGION}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ${KIND_CLUSTER_PREFIX}controller-config
namespace: ${namespace}
data:
AWS_DNS_PUBLIC_ZONE_ID: ${KUADRANT_AWS_DNS_PUBLIC_ZONE_ID}
ZONE_ROOT_DOMAIN: ${KUADRANT_ZONE_ROOT_DOMAIN}
LOG_LEVEL: "${LOG_LEVEL}"
---
apiVersion: kuadrant.io/v1alpha1
kind: ManagedZone
metadata:
name: ${KIND_CLUSTER_PREFIX}dev-mz
namespace: ${namespace}
spec:
id: ${KUADRANT_AWS_DNS_PUBLIC_ZONE_ID}
domainName: ${KUADRANT_ZONE_ROOT_DOMAIN}
description: "Dev Managed Zone"
dnsProviderSecretRef:
name: ${KIND_CLUSTER_PREFIX}aws-credentials
EOF
}

setupGCPProvider() {
local namespace="$1"
if [ -z "$1" ]; then
namespace="multi-cluster-gateways"
fi
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: ${KIND_CLUSTER_PREFIX}gcp-credentials
namespace: ${namespace}
type: "kuadrant.io/gcp"
stringData:
GOOGLE: '${GOOGLE}'
PROJECT_ID: ${PROJECT_ID}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ${KIND_CLUSTER_PREFIX}controller-config
namespace: ${namespace}
data:
ZONE_DNS_NAME: ${ZONE_DNS_NAME}
ZONE_NAME: ${ZONE_NAME}
LOG_LEVEL: "${LOG_LEVEL}"
---
apiVersion: kuadrant.io/v1alpha1
kind: ManagedZone
metadata:
name: ${KIND_CLUSTER_PREFIX}dev-mz
namespace: ${namespace}
spec:
id: ${ZONE_NAME}
domainName: ${ZONE_DNS_NAME}
description: "Dev Managed Zone"
dnsProviderSecretRef:
name: ${KIND_CLUSTER_PREFIX}gcp-credentials
EOF
}

configureController() {
clusterName=${1}
namespace=${2}
kubectl config use-context kind-${clusterName}
echo "Initialize local dev setup for the controller on ${clusterName}"

case $DNS_PROVIDER in
aws)
echo "Setting up an AWS Route 53 DNS provider"
setupAWSProvider ${namespace}
;;
gcp)
echo "Setting up a Google Cloud DNS provider"
setupGCPProvider ${namespace}
;;
*)
echo "Unknown DNS provider"
exit
;;
esac
}


deployQuickStartControl() {
deployMGCHub() {
clusterName=${1}
kubectl config use-context kind-${clusterName}
echo "Initialize quickstart setup on ${clusterName}"
echo "Initialize MGC hub setup on ${clusterName}"
wait_for "${KUSTOMIZE_BIN} --load-restrictor LoadRestrictionsNone build ${QUICK_START_HUB_KUSTOMIZATION} --enable-helm --helm-command ${HELM_BIN} | kubectl apply -f -" "${QUICK_START_HUB_KUSTOMIZATION} control cluster config apply" "1m" "5"
echo "Waiting for metallb-system deployments to be ready"
kubectl -n metallb-system wait --for=condition=ready pod --selector=app=metallb --timeout=300s
echo "Waiting for istio deployments to be ready"
kubectl -n istio-operator wait --timeout=300s --for=condition=Available deployments --all
kubectl -n istio-system wait --timeout=300s --for=condition=Available deployments --all
echo "Waiting for cert-manager deployments to be ready"
kubectl -n cert-manager wait --timeout=300s --for=condition=Available deployments --all
echo "Waiting for kuadrant-operator deployments to be ready"
kubectl -n kuadrant-system wait --timeout=300s --for=condition=Available deployments --all
}

deployQuickStartWorkload() {
deployMGCSpoke() {
clusterName=${1}
kubectl config use-context kind-${clusterName}
echo "Initialize quickstart setup on ${clusterName}"
echo "Initialize MGC spoke setup on ${clusterName}"
wait_for "${KUSTOMIZE_BIN} --load-restrictor LoadRestrictionsNone build ${QUICK_START_SPOKE_KUSTOMIZATION} --enable-helm --helm-command ${HELM_BIN} | kubectl apply -f -" "${QUICK_START_SPOKE_KUSTOMIZATION} workload cluster config apply" "1m" "5"
echo "Waiting for metallb-system deployments to be ready"
kubectl -n metallb-system wait --for=condition=ready pod --selector=app=metallb --timeout=300s
echo "Waiting for istio deployments to be ready"
kubectl -n istio-operator wait --timeout=300s --for=condition=Available deployments --all
wait_for "kubectl -n istio-system wait --for=condition=Available deployments --all" "istio-system deployments" "300s" "20"
kubectl -n istio-system wait --timeout=300s --for=condition=Available deployments --all
}

configureClusterAsIngress() {
Expand All @@ -353,4 +174,4 @@ deployPrometheus() {
kubectl config use-context kind-${clusterName}
echo "Deploying Prometheus in ${clusterName}"
wait_for "${KUSTOMIZE_BIN} --load-restrictor LoadRestrictionsNone build ${PROMETHEUS_DIR} --enable-helm --helm-command ${HELM_BIN} | kubectl apply -f -" "${PROMETHEUS_DIR} cluster config apply" "1m" "5"
}
}
Loading

0 comments on commit 972f32b

Please sign in to comment.