-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ WIP: Feat dedicated hosts #5344
Closed
Closed
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7b0985e
initial proposal for quickstart
faermanj 910d139
fix: correct keypair file assignment and replace cluster description …
faermanj fe5d105
feat: enhance cluster creation script with verification steps for wor…
faermanj 59c3ab5
initial proposal for dedicated hosts
faermanj 708b06d
wip
faermanj e2472c3
Merge branch 'kubernetes-sigs:main' into feat-dedicated-hosts
faermanj d33f4d9
wip
faermanj b19fcaa
fixing dev env
faermanj 79d6e30
wip
faermanj 18c3b2f
devbox wip
faermanj a937b9e
wip
faermanj d2223f4
wip
faermanj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,3 +63,7 @@ dist | |
_artifacts | ||
awsiamconfiguration.yaml | ||
cloudformation.yaml | ||
|
||
# temporary data | ||
tmp | ||
.tmp |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/bin/bash | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
# Load cluster resource configuration | ||
source $DIR/cluster.envrc | ||
|
||
# Create management cluster | ||
kind create cluster | ||
kubectl cluster-info | ||
|
||
# Check AWS Authentication and Account Preparation | ||
aws sts get-caller-identity | ||
|
||
export AWS_SSH_KEY_NAME=${AWS_SSH_KEY_NAME:-"capa-dedicated-hosts"} | ||
if aws ec2 describe-key-pairs --key-names $AWS_SSH_KEY_NAME 2>/dev/null; then | ||
echo "Key pair [$AWS_SSH_KEY_NAME] already exists." | ||
else | ||
KEYPAIR_FILE="$CLUSTER_DIR/${AWS_SSH_KEY_NAME}.pem" | ||
aws ec2 create-key-pair --key-name $AWS_SSH_KEY_NAME --query 'KeyMaterial' --output text > $KEYPAIR_FILE | ||
chmod 400 $KEYPAIR_FILE | ||
ls -l $KEYPAIR_FILE | ||
echo "Key pair [$AWS_SSH_KEY_NAME] created [$KEYPAIR_FILE]." | ||
|
||
fi | ||
|
||
clusterawsadm bootstrap iam create-cloudformation-stack | ||
|
||
export AWS_B64ENCODED_CREDENTIALS=$(clusterawsadm bootstrap credentials encode-as-profile) | ||
echo $AWS_B64ENCODED_CREDENTIALS | ||
|
||
# Initialize the management cluster with AWS provider | ||
clusterctl init --infrastructure aws | ||
|
||
# Create a workload cluster | ||
CLUSTER_DIR=${CLUSTER_DIR:-"tmp"} | ||
mkdir -p $CLUSTER_DIR | ||
|
||
export AWS_CONTROL_PLANE_MACHINE_TYPE=t3.large | ||
export AWS_NODE_MACHINE_TYPE=t3.large | ||
|
||
export AWS_HOST_AZ="us-east-1a" | ||
export AWS_HOST_FAMILY="t3" | ||
|
||
# Allocate dedicated host | ||
aws ec2 allocate-hosts \ | ||
--availability-zone "$AWS_HOST_AZ" \ | ||
--auto-placement "off" \ | ||
--host-recovery "off" \ | ||
--host-maintenance "on" \ | ||
--quantity 1 \ | ||
--instance-family "$AWS_HOST_FAMILY" | tee "$CLUSTER_DIR/host.json" | ||
|
||
export AWS_HOST_ID=$(jq -r '.HostIds[0]' "$CLUSTER_DIR/host.json") | ||
export AWS_HOST_AFFINITY="Default" | ||
echo $AWS_HOST_ID | ||
|
||
export KUBERNETES_VERSION_DEFAULT=$(clusterawsadm ami list -o json | jq -r '.items[0].spec.kubernetesVersion') | ||
export KUBERNETES_VERSION=${KUBERNETES_VERSION:-$KUBERNETES_VERSION_DEFAULT} | ||
echo $KUBERNETES_VERSION | ||
|
||
export CLUSTER_NAME=${CLUSTER_NAME:-"capa-dedicated-hosts"} | ||
|
||
export AWS_HOST_AZ="us-east-1a" | ||
export AWS_HOST_FAMILY="t3" | ||
|
||
# Allocate dedicated host | ||
aws ec2 allocate-hosts \ | ||
--availability-zone "$AWS_HOST_AZ" \ | ||
--auto-placement "off" \ | ||
--host-recovery "off" \ | ||
--host-maintenance "on" \ | ||
--quantity 1 \ | ||
--instance-family "$AWS_HOST_FAMILY" | tee "$CLUSTER_DIR/host.json" | ||
|
||
clusterctl generate cluster $CLUSTER_NAME \ | ||
--from - \ | ||
--kubernetes-version $KUBERNETES_VERSION \ | ||
--control-plane-machine-count=3 \ | ||
--worker-machine-count=3 \ | ||
< templates/cluster-template-dedicated-hosts.yaml \ | ||
> "$CLUSTER_DIR/capa-dedicated-hosts.yaml" | ||
|
||
kubectl apply -f "$CLUSTER_DIR/capa-dedicated-hosts.yaml" | ||
|
||
kubectl get cluster | ||
|
||
watch -n 15 clusterctl describe cluster capa-dedicated-hosts | ||
|
||
kubectl get kubeadmcontrolplane | ||
|
||
# Function to check if kubeadmcontrolplane is initialized | ||
check_initialized() { | ||
kubectl get kubeadmcontrolplane -o json | jq -e '.items[] | select(.status.initialized == true)' > /dev/null 2>&1 | ||
} | ||
|
||
# Loop until the kubeadmcontrolplane is initialized | ||
while true; do | ||
if check_initialized; then | ||
echo "kubeadmcontrolplane is initialized." | ||
break | ||
else | ||
echo "Waiting for kubeadmcontrolplane to be initialized..." | ||
sleep 30 | ||
fi | ||
done | ||
|
||
echo "Fetching workload cluster kubeconfig" | ||
WORKLOAD_KUBECONFIG="$CLUSTER_DIR/capa-dedicated-hosts.kubeconfig" | ||
clusterctl get kubeconfig capa-dedicated-hosts > "$WORKLOAD_KUBECONFIG" | ||
|
||
# Authenticate on docker hub | ||
kubectl create secret docker-registry docker-creds \ | ||
--docker-server='https://index.docker.io/v1/' \ | ||
--docker-username=$DOCKER_USERNAME \ | ||
--docker-password=$DOCKER_PASSWORD \ | ||
--docker-email=$DOCKER_EMAIL | ||
|
||
|
||
echo "Installing Calico CNI" | ||
helm repo add projectcalico https://docs.tigera.io/calico/charts \ | ||
--kubeconfig=$WORKLOAD_KUBECONFIG | ||
|
||
helm install calico projectcalico/tigera-operator \ | ||
--kubeconfig=$WORKLOAD_KUBECONFIG \ | ||
-f https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-provider-azure/main/templates/addons/calico/values.yaml \ | ||
--namespace tigera-operator \ | ||
--create-namespace | ||
|
||
|
||
# Patch Calico to use Docker Hub credentials | ||
kubectl --kubeconfig=$WORKLOAD_KUBECONFIG patch daemonset \ | ||
-n kube-system calico-node \ | ||
-p '{"spec":{"template":{"spec":{"imagePullSecrets":[{"name":"docker-creds"}]}}}}' | ||
|
||
|
||
# Verify that the workload cluster is up and running | ||
|
||
kubectl --kubeconfig=$WORKLOAD_KUBECONFIG cluster-info | ||
kubectl --kubeconfig=$WORKLOAD_KUBECONFIG get nodes | ||
kubectl --kubeconfig=$WORKLOAD_KUBECONFIG get pods -n kube-system | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
kubectl delete cluster capa-quickstart | ||
kind delete cluster | ||
aws ec2 release-hosts --host-ids $AWS_HOST_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export AWS_REGION="us-east-1" | ||
export AWS_CONTROL_PLANE_MACHINE_TYPE="t3.large" | ||
export AWS_NODE_MACHINE_TYPE="t3.large" | ||
export KUBERNETES_VERSION="1.30.5" | ||
# export AWS_HOST_ID="host-0" | ||
# export AWS_HOST_AFFINITY="Default" | ||
# export DOCKER_USERNAME="" | ||
# export DOCKER_PASSWORD="" | ||
# export DOCKER_EMAIL="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind create cluster | ||
clusterctl init --core cluster-api:v1.8.6 --bootstrap kubeadm:v1.8.6 --control-plane kubeadm:v1.8.6 | ||
make e2e-image | ||
RELEASE_TAG="e2e" make release-manifests | ||
kubectl apply -f ./out/infrastructure.yaml |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll then have issues with the fuzzy tests.