mirror of
https://github.com/fluxcd/flux2-hub-spoke-example.git
synced 2025-07-27 15:53:19 +00:00
Add fleet provisioning scripts
This commit is contained in:
parent
078241aa82
commit
df51542b21
3 changed files with 95 additions and 0 deletions
56
scripts/fleet-up.sh
Executable file
56
scripts/fleet-up.sh
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script creates a fleet of Kubernetes clusters using kind.
|
||||
|
||||
# Copyright 2024 The Flux authors. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Prerequisites
|
||||
# - docker v25.0
|
||||
# - kind v0.22
|
||||
# - kubectl v1.29
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
repo_root=$(git rev-parse --show-toplevel)
|
||||
mkdir -p "${repo_root}/bin"
|
||||
|
||||
CLUSTER_VERSION="${CLUSTER_VERSION:=v1.29.2}"
|
||||
|
||||
CLUSTER_HUB="flux-hub"
|
||||
echo "INFO - Creating cluster ${CLUSTER_HUB}"
|
||||
|
||||
kind create cluster --name "${CLUSTER_HUB}" \
|
||||
--image "kindest/node:${CLUSTER_VERSION}" \
|
||||
--wait 5m
|
||||
|
||||
CLUSTER_STAGING="flux-staging"
|
||||
echo "INFO - Creating cluster ${CLUSTER_STAGING}"
|
||||
|
||||
kind create cluster --name "${CLUSTER_STAGING}" \
|
||||
--image "kindest/node:${CLUSTER_VERSION}" \
|
||||
--wait 5m
|
||||
|
||||
CLUSTER_PRODUCTION="flux-production"
|
||||
echo "INFO - Creating cluster ${CLUSTER_PRODUCTION}"
|
||||
|
||||
kind create cluster --name "${CLUSTER_PRODUCTION}" \
|
||||
--image "kindest/node:${CLUSTER_VERSION}" \
|
||||
--wait 5m
|
||||
|
||||
echo "INFO - Creating kubeconfig secrets in the hub cluster"
|
||||
|
||||
kubectl config use-context "kind-${CLUSTER_HUB}"
|
||||
|
||||
kind get kubeconfig --internal --name ${CLUSTER_STAGING} > "${repo_root}/bin/staging.kubeconfig"
|
||||
kubectl --context "kind-${CLUSTER_HUB}" create ns staging
|
||||
kubectl --context "kind-${CLUSTER_HUB}" create secret generic -n staging cluster-kubeconfig \
|
||||
--from-file=value="${repo_root}/bin/staging.kubeconfig"
|
||||
|
||||
kind get kubeconfig --internal --name ${CLUSTER_PRODUCTION} > "${repo_root}/bin/production.kubeconfig"
|
||||
kubectl --context "kind-${CLUSTER_HUB}" create ns production
|
||||
kubectl --context "kind-${CLUSTER_HUB}" create secret generic -n production cluster-kubeconfig \
|
||||
--from-file=value="${repo_root}/bin/production.kubeconfig"
|
||||
|
||||
echo "INFO - Clusters created successfully"
|
37
scripts/flux-up.sh
Executable file
37
scripts/flux-up.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script configures Flux on the hub cluster.
|
||||
|
||||
# Copyright 2024 The Flux authors. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
repo_root=$(git rev-parse --show-toplevel)
|
||||
mkdir -p "${repo_root}/bin"
|
||||
|
||||
CLUSTER_VERSION="${CLUSTER_VERSION:=v1.29.2}"
|
||||
|
||||
CLUSTER_HUB="flux-hub"
|
||||
|
||||
echo "INFO - Installing Flux in the hub cluster"
|
||||
|
||||
flux --context "kind-${CLUSTER_HUB}" install \
|
||||
--components-extra=image-reflector-controller,image-automation-controller
|
||||
|
||||
flux --context "kind-${CLUSTER_HUB}" create source git flux-system \
|
||||
--url=https://github.com/fluxcd/flux2-hub-spoke-example \
|
||||
--branch=main \
|
||||
--interval=1m \
|
||||
--username=git \
|
||||
--password=${GITHUB_TOKEN}
|
||||
|
||||
flux --context "kind-${CLUSTER_HUB}" create kustomization flux-system \
|
||||
--source=GitRepository/flux-system \
|
||||
--ignore-paths="hub/flux-system/"
|
||||
--path="./hub" \
|
||||
--prune=true \
|
||||
--interval=10m
|
||||
|
||||
echo "INFO - Flux configured successfully"
|
Loading…
Add table
Add a link
Reference in a new issue