Using cluster-api-provider-aws:
clusterctl create cluster -v 3 --bootstrap-type kind --provider aws -m ./cmd/clusterctl/examples/aws/out/machines.yaml -c ./cmd/clusterctl/examples/aws/out/cluster.yaml -p ./cmd/clusterctl/examples/aws/out/provider-components.yaml -a ./cmd/clusterctl/examples/aws/out/addons.yaml
After the cluster creation starts, hit ctrl-c and then delete the controlplane-0
machine:
kubectl --kubeconfig=$(kind get kubeconfig-path --name clusterapi) delete machine controlplane-0
Spin up a second KIND cluster to pivot to:
kind create cluster --name dest
Using the pivotPhase
branch from github.com/detiber/cluster-api build clusterctl:
make clusterctl
Run the pivot phase:
bin/clusterctl alpha phases pivot -p ~/go/src/sigs.k8s.io/cluster-api-provider-aws/cmd/clusterctl/examples/aws/out/provider-components.yaml --source-kubeconfig $(kind get kubeconfig-path --name clusterapi) --target-kubeconfig=$(kind get kubeconfig-path --name dest)
Pivot back to the original cluster:
bin/clusterctl alpha phases pivot -p ~/go/src/sigs.k8s.io/cluster-api-provider-aws/cmd/clusterctl/examples/aws/out/provider-components.yaml --target-kubeconfig $(kind get kubeconfig-path --name clusterapi) --source-kubeconfig=$(kind get kubeconfig-path --name dest)
Using cluster-api-provider-aws (this uses old pivoting logic):
clusterctl create cluster -v 3 --bootstrap-type kind --provider aws -m ./cmd/clusterctl/examples/aws/out/machines.yaml -c ./cmd/clusterctl/examples/aws/out/cluster.yaml -p ./cmd/clusterctl/examples/aws/out/provider-components.yaml -a ./cmd/clusterctl/examples/aws/out/addons.yaml
Spin up a KIND cluster to pivot to:
kind create cluster --name dest
Add a MachineSet:
cat << EOF | kubectl --kubeconfig=kubeconfig create -f -
apiVersion: "cluster.k8s.io/v1alpha1"
kind: MachineSet
metadata:
name: nodeset1
spec:
replicas: 1
selector:
matchLabels:
set: node
node-set: "1"
template:
metadata:
labels:
set: node
node-set: "1"
spec:
versions:
kubelet: v1.13.2
providerSpec:
value:
apiVersion: awsprovider/v1alpha1
kind: AWSMachineProviderSpec
instanceType: "t2.medium"
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
keyName: "default"
EOF
Add a MachineDeployment:
cat << EOF | kubectl --kubeconfig=kubeconfig create -f -
apiVersion: "cluster.k8s.io/v1alpha1"
kind: MachineDeployment
metadata:
name: nodedeployment1
spec:
replicas: 1
selector:
matchLabels:
set: node
node-deployment: "1"
template:
metadata:
labels:
set: node
node-deployment: "1"
spec:
versions:
kubelet: v1.13.2
providerSpec:
value:
apiVersion: awsprovider/v1alpha1
kind: AWSMachineProviderSpec
instanceType: "t2.medium"
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
keyName: "default"
EOF
Using the pivotPhase
branch from github.com/detiber/cluster-api build clusterctl:
make clusterctl
Run the pivot phase:
bin/clusterctl alpha phases pivot -v 4 -p ~/go/src/sigs.k8s.io/cluster-api-provider-aws/cmd/clusterctl/examples/aws/out/provider-components.yaml --source-kubeconfig ~/go/src/sigs.k8s.io/cluster-api-provider-aws/kubeconfig --target-kubeconfig=$(kind get kubeconfig-path --name dest)
Pivot back to the original cluster:
bin/clusterctl alpha phases pivot -v 4 -p ~/go/src/sigs.k8s.io/cluster-api-provider-aws/cmd/clusterctl/examples/aws/out/provider-components.yaml --target-kubeconfig ~/go/src/sigs.k8s.io/cluster-api-provider-aws/kubeconfig --source-kubeconfig=$(kind get kubeconfig-path --name dest)