Skip to content

Commit

Permalink
Fix CAPD deployment using phase plan
Browse files Browse the repository at this point in the history
This PS introduces phase plan for CAPD provider
 * Adds phase to merge kubeconfig
 * Patches type/gating plan to use capd phase plan
 * Patches cluster_map and executor to work with "default" namespace
 * Fixes CAPD zuul failures

Relates-To: #564
Relates-To: #580
Relates-To: #587
Change-Id: I5007970c907bc87dccf6dd9fcb052afc1b5c13f7
  • Loading branch information
Ratnopam Chakrabarti committed Sep 7, 2021
1 parent 0cb8e0f commit 441ef0e
Show file tree
Hide file tree
Showing 20 changed files with 123 additions and 189 deletions.
2 changes: 2 additions & 0 deletions manifests/function/capd/v0.3.11/data/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- metadata.yaml
11 changes: 11 additions & 0 deletions manifests/function/capd/v0.3.11/data/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
kind: Metadata
metadata:
name: repository-metadata
labels:
airshipit.org/deploy-k8s: "false"
releaseSeries:
- major: 0
minor: 3
contract: v1alpha3
1 change: 1 addition & 0 deletions manifests/function/capd/v0.3.11/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ commonLabels:

resources:
- crd
- data
- default
- webhook
1 change: 1 addition & 0 deletions manifests/function/phase-helpers/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ resources:
- wait_bmh
- wait_label_node
- check_ingress_ctrl
- merge_kubeconfig
15 changes: 4 additions & 11 deletions .../provider_common/34_deploy_worker_node.sh → ...ge_kubeconfig/kubectl_merge_kubeconfig.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,16 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -xe
set -ex

export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"}
export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"}
KUBECONFIG=${KUBECONFIG}:${TGT_KUBECONFIG} kubectl config view --flatten > /tmp/kubeconfig-trans

echo "Stop/Delete ephemeral node"
kind delete cluster --name "ephemeral-cluster"
cat /tmp/kubeconfig-trans > ${TGT_KUBECONFIG}

echo "Deploy worker node"
airshipctl phase run workers-target --debug

#Wait till node is created
kubectl wait --for=condition=ready node --all --timeout=1000s --context $KUBECONFIG_TARGET_CONTEXT --kubeconfig $KUBECONFIG -A
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
configMapGenerator:
- name: merge-kubeconfig
options:
disableNameSuffixHash: true
files:
- script=kubectl_merge_kubeconfig.sh
22 changes: 22 additions & 0 deletions manifests/phases/executors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,25 @@ spec:
type: krm
image: localhost/clusterctl:latest
hostNetwork: true
---
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
metadata:
name: merge-kubeconfig
labels:
airshipit.org/deploy-k8s: "false"
spec:
type: krm
image: quay.io/airshipit/toolbox:latest
hostNetwork: true
envVars:
- TGT_KUBECONFIG=/tmp-kubeconfig
mounts:
- type: bind
src: ~/.airship/kubeconfig
dst: /tmp-kubeconfig
rw: true
configRef:
kind: ConfigMap
name: merge-kubeconfig
apiVersion: v1
11 changes: 11 additions & 0 deletions manifests/phases/phases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,14 @@ config:
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
name: kubectl-check-ingress-ctrl
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: kubectl-merge-kubeconfig
clusterName: target-cluster
config:
executorRef:
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
name: merge-kubeconfig
2 changes: 2 additions & 0 deletions manifests/site/docker-test-site/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- metadata.yaml
22 changes: 22 additions & 0 deletions manifests/site/docker-test-site/phases/cluster_map_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: airshipit.org/v1alpha1
kind: ClusterMap
metadata:
labels:
airshipit.org/deploy-k8s: "false"
name: main-map
map:
target-cluster:
parent: ephemeral-cluster
kubeconfigSources:
- type: "filesystem"
filesystem:
path: ~/.airship/kubeconfig
contextName: target-cluster
- type: "bundle"
bundle:
contextName: target-cluster
- type: "clusterAPI"
clusterAPI:
clusterNamespacedName:
name: target-cluster
namespace: default
7 changes: 7 additions & 0 deletions manifests/site/docker-test-site/phases/executor_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: airshipit.org/v1alpha1
kind: Clusterctl
metadata:
name: clusterctl_move
move-options:
namespace: default
action: move
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
[{
"op": "replace",
"path": "/init-options/infrastructure-providers",
"value": ["docker:v0.3.11"]
"value": "docker:v0.3.11"
},
{
"op": "replace",
"path": "/providers/0",
"value": {
"name": "docker",
"type": "InfrastructureProvider",
"variable-substitution": true,
"versions": {
"v0.3.11": "airshipctl/manifests/function/capd/v0.3.11"
}
"url": "airshipctl/manifests/function/capd/v0.3.11"
}
}
]
5 changes: 4 additions & 1 deletion manifests/site/docker-test-site/phases/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
resources:
- ../../../phases
- ../../../function/airshipctl-base-catalogues
- plan.yaml
patchesJson6902:
- target:
group: airshipit.org
version: v1alpha1
kind: Clusterctl
name: "clusterctl_init"
path: infrastructure-providers.json
patchesStrategicMerge:
- plan_patch.yaml
- cluster_map_patch.yaml
- executor_patch.yaml
transformers:
- ../../../function/clusterctl/replacements
- ../../../phases/replacements
11 changes: 0 additions & 11 deletions manifests/site/docker-test-site/phases/plan.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions manifests/site/docker-test-site/phases/plan_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: airshipit.org/v1alpha1
kind: PhasePlan
metadata:
name: deploy-gating
description: "Phase plan for docker-test-site deployment"
phases:
- name: clusterctl-init-ephemeral
- name: kubectl-wait-deploy-ephemeral
- name: kubectl-get-pods-ephemeral
- name: controlplane-ephemeral
- name: kubectl-merge-kubeconfig
- name: kubectl-get-node-target
- name: kubectl-get-pods-target
- name: initinfra-networking-target
- name: kubectl-wait-tigera-target
- name: kubectl-get-pods-target
- name: clusterctl-init-target
- name: kubectl-wait-pods-any-ephemeral
- name: clusterctl-move
- name: workers-target
5 changes: 5 additions & 0 deletions tools/deployment/kind/start_kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ set -xe
: ${KUBECONFIG:="${HOME}/.airship/kubeconfig"}
: ${TIMEOUT:=3600}
: ${KIND_CONFIG:=""}

export KIND_EXPERIMENTAL_DOCKER_NETWORK=bridge
export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"}

echo "cluster name: $CLUSTER";

Expand All @@ -58,5 +60,8 @@ kubectl wait --for=condition=ready node --all --timeout=1000s --kubeconfig $KUBE
# By default, kind creates context kind-<cluster_name>
kubectl config set-context ${CLUSTER} --cluster kind-${CLUSTER} --user kind-${CLUSTER} --kubeconfig $KUBECONFIG

# Add context for target-cluster
kubectl config set-context ${KUBECONFIG_TARGET_CONTEXT} --user target-cluster-admin --cluster ${KUBECONFIG_TARGET_CONTEXT} --kubeconfig $KUBECONFIG

echo "This cluster can be deleted via:"
echo "${KIND} delete cluster --name ${CLUSTER}"
46 changes: 0 additions & 46 deletions tools/deployment/provider_common/30_deploy_controlplane.sh

This file was deleted.

39 changes: 0 additions & 39 deletions tools/deployment/provider_common/32_cluster_init_target_node.sh

This file was deleted.

69 changes: 0 additions & 69 deletions tools/deployment/provider_common/33_cluster_move_target_node.sh

This file was deleted.

Loading

0 comments on commit 441ef0e

Please sign in to comment.