Created
January 22, 2019 19:52
-
-
Save chuckha/a9e260c5e34b8de6063e9fdfe7e247cb to your computer and use it in GitHub Desktop.
Testing machine deployment script
This file contains hidden or 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
#!/usr/bin/env bash | |
set -o xtrace | |
set -o errexit | |
set -o nounset | |
cleanup() { | |
source envfile | |
aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId]" | jq '.[][0][0]' --raw-output | xargs aws ec2 terminate-instances --instance-ids | |
} | |
kind create cluster --image kindest/node:latest | |
KUBECONFIG="$(kind get kubeconfig-path --name=1)" | |
clusterctl alpha phases apply-cluster-api-components -p ./cmd/clusterctl/examples/aws/out/provider-components.yaml --kubeconfig "${KUBECONFIG}" | |
cat <<EOF | kubectl apply --kubeconfig "${KUBECONFIG}" -f - | |
apiVersion: "cluster.k8s.io/v1alpha1" | |
kind: Cluster | |
metadata: | |
name: test1 | |
spec: | |
clusterNetwork: | |
services: | |
cidrBlocks: ["10.96.0.0/12"] | |
pods: | |
cidrBlocks: ["192.168.0.0/16"] | |
serviceDomain: "cluster.local" | |
providerSpec: | |
value: | |
apiVersion: "awsprovider/v1alpha1" | |
kind: "AWSClusterProviderSpec" | |
region: "us-west-2" | |
sshKeyName: "laptop" | |
EOF | |
read -p "once the infra is done is done push enter to continue setting up the control plane" | |
cat <<EOF | kubectl apply --kubeconfig "${KUBECONFIG}" -f - | |
apiVersion: "cluster.k8s.io/v1alpha1" | |
kind: Machine | |
metadata: | |
name: aws-controlplane-0 | |
labels: | |
set: controlplane | |
spec: | |
versions: | |
kubelet: v1.13.0 | |
controlPlane: v1.13.0 | |
providerSpec: | |
value: | |
apiVersion: awsprovider/v1alpha1 | |
kind: AWSMachineProviderSpec | |
instanceType: "t2.medium" | |
iamInstanceProfile: "control-plane.cluster-api-provider-aws.sigs.k8s.io" | |
keyName: "laptop" | |
EOF | |
read -p "once the control plane is provisioined push enter to set up the machine deployment" | |
cat <<EOF | kubectl apply --kubeconfig "${KUBECONFIG}" -f - | |
apiVersion: "cluster.k8s.io/v1alpha1" | |
kind: MachineDeployment | |
metadata: | |
name: nodes | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
set: node | |
template: | |
metadata: | |
labels: | |
set: node | |
spec: | |
versions: | |
kubelet: v1.13.0 | |
providerSpec: | |
value: | |
apiVersion: awsprovider/v1alpha1 | |
kind: AWSMachineProviderSpec | |
instanceType: "t2.medium" | |
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io" | |
keyName: "laptop" | |
EOF | |
read -p "press enter to clean up all instances" | |
cleanup | |
kind delete cluster 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment