Skip to content

Instantly share code, notes, and snippets.

@detiber
Last active February 15, 2019 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save detiber/ab3b71278d056e43e5a7e71b429cb16c to your computer and use it in GitHub Desktop.
Save detiber/ab3b71278d056e43e5a7e71b429cb16c to your computer and use it in GitHub Desktop.
Pivot testing

Pivot Testing

Initial testing, no Machine* objects, only a Cluster object in the default namespace.

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)

MachineDeployment, MachineSet, and Machine testing, single controlplane Machine.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment