Skip to content

Instantly share code, notes, and snippets.

@faermanj
Last active April 10, 2025 08:08
Show Gist options
  • Save faermanj/51f47ea0f11199f0331ccc723476f19c to your computer and use it in GitHub Desktop.
Save faermanj/51f47ea0f11199f0331ccc723476f19c to your computer and use it in GitHub Desktop.
CAPA Tilt
# System Check / Fixes
chmod 400 /home/vscode/.ssh/id_rsa
# Environment Settings (.envrc )
export KUBERNETES_VERSION="v1.30.8"
export CLUSTER_NAME="capi-test"
export USE_EXISTING_CLUSTER="true"
# Start devbox
devbox shell
direnv allow
source .envrc
echo $AWS_REGION $CLUSTER_NAME $KUBERNETES_VERSION
# Create management cluster
kind create cluster \
--name=$CLUSTER_NAME \
--image kindest/node:$KUBERNETES_VERSION
# CAPI-AWS
mkdir -p $HOME/go/src/sigs.k8s.io
pushd $HOME/go/src/sigs.k8s.io
# ln -s /workspaces/cluster-api-provider-aws-f0 /workspaces/cluster-api-provider-aws
ln -s /workspaces/cluster-api-provider-aws $HOME/go/src/sigs.k8s.io/cluster-api-provider-aws
# git clone [email protected]:kubernetes-sigs/cluster-api-provider-aws.git
# git clone [email protected]:faermanj/cluster-api-provider-aws-f0.git
cd cluster-api-provider-aws
make clusterawsadm
mkdir -p $HOME/.local/bin
ln -s $HOME/go/src/sigs.k8s.io/cluster-api-provider-aws/bin/clusterawsadm $HOME/.local/bin/clusterawsadm
aws sts get-caller-identity
cat <<EOF > config-bootstrap.yaml
apiVersion: bootstrap.aws.infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSIAMConfiguration
spec:
bootstrapUser:
enable: true
stackTags:
capa-e2e-test: "true"
EOF
clusterawsadm bootstrap iam create-cloudformation-stack --config config-bootstrap.yaml --region $AWS_REGION
export AWS_B64ENCODED_CREDENTIALS=$(clusterawsadm bootstrap credentials encode-as-profile)
echo $AWS_B64ENCODED_CREDENTIALS | base64 -d
# CAPI
export CAPI_VERSION=$(grep 'cluster-api v' go.mod | cut -d' ' -f2)
echo $CAPI_VERSION
cd $HOME/go/src/sigs.k8s.io/
git clone [email protected]:kubernetes-sigs/cluster-api.git
cd cluster-api
git fetch origin tag $CAPI_VERSION
git checkout $CAPI_VERSION
# Define variables
export CAPA_REPO_PATH="$HOME/go/src/sigs.k8s.io/cluster-api-provider-aws"
export OUTPUT_FILE="tilt-settings.json"
export CAPA_REGISTRY="gcr.io/capa-dev"
# Create the Tilt settings file
cat <<EOF > "$OUTPUT_FILE"
{
"enable_providers": [
"kubeadm-bootstrap",
"kubeadm-control-plane",
"aws"
],
"default_registry": "$CAPA_REGISTRY",
"provider_repos": [
"$CAPA_REPO_PATH"
],
"kustomize_substitutions": {
"EXP_CLUSTER_RESOURCE_SET": "true",
"EXP_MACHINE_POOL": "true",
"EVENT_BRIDGE_INSTANCE_STATE": "true",
"AWS_B64ENCODED_CREDENTIALS": "$AWS_B64ENCODED_CREDENTIALS",
"EXP_EKS_FARGATE": "false",
"CAPA_EKS_IAM": "false",
"CAPA_EKS_ADD_ROLES": "false",
"EXP_BOOTSTRAP_FORMAT_IGNITION": "true"
},
"extra_args": {
"aws": ["--v=2"]
}
}
EOF
cat tilt-settings.json
tilt up
# s to stream logs
# open https://localhost:10350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment