From 803aaf6b41352bd8c563cd2ea70c7dd9b0b9e83c Mon Sep 17 00:00:00 2001 From: prankul88 Date: Tue, 1 Oct 2019 14:50:43 +0530 Subject: [PATCH 1/3] Generate seperate multi-node and single-node yaml Updated documentation --- docs/config.md | 2 +- examples/README.md | 6 +- .../cluster/{ => multi-node}/cluster.yaml | 12 +- .../{ => multi-node}/kustomization.yaml | 0 .../{ => multi-node}/kustomizeconfig.yaml | 0 examples/cluster/single-node/cluster.yaml | 42 +++++++ .../cluster/single-node/kustomization.yaml | 7 ++ .../cluster/single-node/kustomizeconfig.yaml | 6 + .../{ => multi-node}/controlplane.yaml | 30 +++-- .../{ => multi-node}/kustomization.yaml | 0 .../{ => multi-node}/kustomizeconfig.yaml | 0 .../single-node/controlplane.yaml | 106 ++++++++++++++++++ .../single-node/kustomization.yaml | 7 ++ .../single-node/kustomizeconfig.yaml | 15 +++ examples/generate.sh | 28 ++++- .../machinedeployment/machinedeployment.yaml | 6 + 16 files changed, 236 insertions(+), 31 deletions(-) rename examples/cluster/{ => multi-node}/cluster.yaml (72%) rename examples/cluster/{ => multi-node}/kustomization.yaml (100%) rename examples/cluster/{ => multi-node}/kustomizeconfig.yaml (100%) create mode 100644 examples/cluster/single-node/cluster.yaml create mode 100644 examples/cluster/single-node/kustomization.yaml create mode 100644 examples/cluster/single-node/kustomizeconfig.yaml rename examples/controlplane/{ => multi-node}/controlplane.yaml (91%) rename examples/controlplane/{ => multi-node}/kustomization.yaml (100%) rename examples/controlplane/{ => multi-node}/kustomizeconfig.yaml (100%) create mode 100644 examples/controlplane/single-node/controlplane.yaml create mode 100644 examples/controlplane/single-node/kustomization.yaml create mode 100644 examples/controlplane/single-node/kustomizeconfig.yaml diff --git a/docs/config.md b/docs/config.md index 359a79ee31..b1bdd0f84b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -34,7 +34,7 @@ To successfully run a Kubernetes cluster in OpenStack, you will need to configur ## Cluster and machines YAML files -After running `examples/generate.sh` the YAML files will be created in `examples/_out` (or your custom output folder). This files contain configuration on what OpenStack elements to use to create the cluster on, and which cluster components to create. However the template is incomplete and needs to be filled in. The following sections explain some more details about what can be configured. +After running `examples/generate.sh` the YAML files will be created in your custom output folder. This files contain configuration on what OpenStack elements to use to create the cluster on, and which cluster components to create. However the template is incomplete and needs to be filled in. The following sections explain some more details about what can be configured. ## Private Network diff --git a/examples/README.md b/examples/README.md index 5c9788bb60..996ba94302 100644 --- a/examples/README.md +++ b/examples/README.md @@ -27,7 +27,7 @@ For convenience, a script is provided which generates example YAMLs. The generat ``` cd examples export CLUSTER_NAME= -./generate.sh [options] [output folder] +./generate.sh [options] [single/multi-node] ``` `` is a YAML configuration file for Openstack, for more details refer to [OpenStack client configuration files](https://docs.openstack.org/python-openstackclient/latest/configuration/index.html#configuration-files). @@ -51,7 +51,9 @@ export CLUSTER_NAME= In case your OpenStack cluster endpoint is using SSL and the cert is signed by an unknown CA, a specific CA certificate can be provided via the cacert field. - `[output folder]` is where the YAML files will be stored, by default it's `_out`. + `` is where the YAML files will be stored. + + `[single/multi-node]` is for the control plane preference, by default it's `single-node` . ## Manual Modification diff --git a/examples/cluster/cluster.yaml b/examples/cluster/multi-node/cluster.yaml similarity index 72% rename from examples/cluster/cluster.yaml rename to examples/cluster/multi-node/cluster.yaml index f540f5b37d..1aa32dd700 100644 --- a/examples/cluster/cluster.yaml +++ b/examples/cluster/multi-node/cluster.yaml @@ -11,11 +11,6 @@ spec: pods: cidrBlocks: ["192.168.0.0/16"] serviceDomain: "cluster.local" - # multi-node control-plane: - # * Disable the apiServerPort property - # single-node control-plane: - # * Enable the apiServerPort property - apiServerPort: infrastructureRef: apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 kind: OpenStackCluster @@ -33,12 +28,6 @@ spec: name: cloud-config namespace: ${CLUSTER_NAME} nodeCidr: - # multi-node control-plane: - # * Enable the following section to use a Loadbalancer - # which is required for multi-node control plane - # single-node control-plane: - # * Disable the following section to deploy a single node - # control plane managedAPIServerLoadBalancer: true apiServerLoadBalancerFloatingIP: apiServerLoadBalancerPort: 6443 @@ -54,3 +43,4 @@ spec: managedSecurityGroups: false disablePortSecurity: true disableServerTags: true + useOctavia: true diff --git a/examples/cluster/kustomization.yaml b/examples/cluster/multi-node/kustomization.yaml similarity index 100% rename from examples/cluster/kustomization.yaml rename to examples/cluster/multi-node/kustomization.yaml diff --git a/examples/cluster/kustomizeconfig.yaml b/examples/cluster/multi-node/kustomizeconfig.yaml similarity index 100% rename from examples/cluster/kustomizeconfig.yaml rename to examples/cluster/multi-node/kustomizeconfig.yaml diff --git a/examples/cluster/single-node/cluster.yaml b/examples/cluster/single-node/cluster.yaml new file mode 100644 index 0000000000..e992334e4b --- /dev/null +++ b/examples/cluster/single-node/cluster.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: cluster.x-k8s.io/v1alpha2 +kind: Cluster +metadata: + name: ${CLUSTER_NAME} + namespace: ${CLUSTER_NAME} +spec: + clusterNetwork: + services: + cidrBlocks: ["10.96.0.0/12"] + pods: + cidrBlocks: ["192.168.0.0/16"] + serviceDomain: "cluster.local" + apiServerPort: 6443 + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 + kind: OpenStackCluster + name: ${CLUSTER_NAME} + namespace: ${CLUSTER_NAME} +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 +kind: OpenStackCluster +metadata: + name: ${CLUSTER_NAME} + namespace: ${CLUSTER_NAME} +spec: + cloudName: $CLOUD + cloudsSecret: + name: cloud-config + namespace: ${CLUSTER_NAME} + nodeCidr: + managedAPIServerLoadBalancer: false + dnsNameservers: [] + # multi-node control-plane: + # * externalNetworkId is required for: + # * creating routers + # * creating floating ips + # * creating load balancer + externalNetworkId: + managedSecurityGroups: false + disablePortSecurity: true + disableServerTags: true diff --git a/examples/cluster/single-node/kustomization.yaml b/examples/cluster/single-node/kustomization.yaml new file mode 100644 index 0000000000..d3e20f6823 --- /dev/null +++ b/examples/cluster/single-node/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: ${CLUSTER_NAME} +resources: +- cluster.yaml +configurations: +- kustomizeconfig.yaml diff --git a/examples/cluster/single-node/kustomizeconfig.yaml b/examples/cluster/single-node/kustomizeconfig.yaml new file mode 100644 index 0000000000..a018a3828e --- /dev/null +++ b/examples/cluster/single-node/kustomizeconfig.yaml @@ -0,0 +1,6 @@ +namespace: +- kind: Cluster + group: cluster.x-k8s.io + version: v1alpha2 + path: spec/infrastructureRef/namespace + create: true diff --git a/examples/controlplane/controlplane.yaml b/examples/controlplane/multi-node/controlplane.yaml similarity index 91% rename from examples/controlplane/controlplane.yaml rename to examples/controlplane/multi-node/controlplane.yaml index d58a4408a2..aba091eaea 100644 --- a/examples/controlplane/controlplane.yaml +++ b/examples/controlplane/multi-node/controlplane.yaml @@ -33,11 +33,12 @@ spec: image: sshKeyName: cluster-api-provider-openstack availabilityZone: nova - # multi-node control-plane: - # * Disable the floatingIP property - # single-node control-plane: - # * Enable the floatingIP property - #floatingIP: + networks: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} + subnets: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} cloudName: $CLOUD cloudsSecret: name: cloud-config @@ -77,12 +78,7 @@ spec: cloud-provider: openstack cloud-config: /etc/kubernetes/cloud.conf clusterConfiguration: - # multi-node control-plane: - # * Configure the floating ip of the loadbalancer - # single-node control-plane: - # * Configure the floating ip of the (only) control - # plane node - controlPlaneEndpoint: ":6443" + controlPlaneEndpoint: ":6443" kubernetesVersion: 1.15.0 imageRepository: k8s.gcr.io apiServer: @@ -142,6 +138,12 @@ spec: image: sshKeyName: cluster-api-provider-openstack availabilityZone: nova + networks: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} + subnets: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} cloudName: $CLOUD cloudsSecret: name: cloud-config @@ -217,6 +219,12 @@ spec: image: sshKeyName: cluster-api-provider-openstack availabilityZone: nova + networks: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} + subnets: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} cloudName: $CLOUD cloudsSecret: name: cloud-config diff --git a/examples/controlplane/kustomization.yaml b/examples/controlplane/multi-node/kustomization.yaml similarity index 100% rename from examples/controlplane/kustomization.yaml rename to examples/controlplane/multi-node/kustomization.yaml diff --git a/examples/controlplane/kustomizeconfig.yaml b/examples/controlplane/multi-node/kustomizeconfig.yaml similarity index 100% rename from examples/controlplane/kustomizeconfig.yaml rename to examples/controlplane/multi-node/kustomizeconfig.yaml diff --git a/examples/controlplane/single-node/controlplane.yaml b/examples/controlplane/single-node/controlplane.yaml new file mode 100644 index 0000000000..47398b494e --- /dev/null +++ b/examples/controlplane/single-node/controlplane.yaml @@ -0,0 +1,106 @@ +##################################################### +# ${CLUSTER_NAME}-controlplane-0 +##################################################### +apiVersion: cluster.x-k8s.io/v1alpha2 +kind: Machine +metadata: + name: ${CLUSTER_NAME}-controlplane-0 + namespace: ${CLUSTER_NAME} + labels: + cluster.x-k8s.io/control-plane: "true" + cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" +spec: + version: ${KUBERNETES_VERSION} + bootstrap: + configRef: + apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2 + kind: KubeadmConfig + name: ${CLUSTER_NAME}-controlplane-0 + namespace: ${CLUSTER_NAME} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 + kind: OpenStackMachine + name: ${CLUSTER_NAME}-controlplane-0 + namespace: ${CLUSTER_NAME} +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 +kind: OpenStackMachine +metadata: + name: ${CLUSTER_NAME}-controlplane-0 + namespace: ${CLUSTER_NAME} +spec: + flavor: m1.medium + image: + sshKeyName: cluster-api-provider-openstack + availabilityZone: nova + networks: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} + subnets: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} + floatingIP: + cloudName: $CLOUD + cloudsSecret: + name: cloud-config + namespace: ${CLUSTER_NAME} +--- +apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2 +kind: KubeadmConfig +metadata: + name: ${CLUSTER_NAME}-controlplane-0 + namespace: ${CLUSTER_NAME} +spec: + files: + - path: /etc/kubernetes/cloud.conf + owner: root + permissions: "0600" + content: |- + # cloud.conf to communicate with OpenStack + $OPENSTACK_CLOUD_PROVIDER_CONF6 + - path: /etc/certs/cacert + owner: root + permissions: "0600" + content: | + $OPENSTACK_CLOUD_CACERT_CONFIG6 + ntp: + servers: [] + users: + - name: ubuntu + sshAuthorizedKeys: + - "$MACHINE_CONTROLLER_SSH_PUBLIC_FILE_CONTENT" + initConfiguration: + localAPIEndpoint: + advertiseAddress: '{{ ds.ec2_metadata.local_ipv4 }}' + bindPort: 6443 + nodeRegistration: + name: '{{ local_hostname }}' + kubeletExtraArgs: + cloud-provider: openstack + cloud-config: /etc/kubernetes/cloud.conf + clusterConfiguration: + controlPlaneEndpoint: ":6443" + kubernetesVersion: 1.15.0 + imageRepository: k8s.gcr.io + apiServer: + extraArgs: + cloud-provider: openstack + cloud-config: /etc/kubernetes/cloud.conf + extraVolumes: + - name: cloud + hostPath: /etc/kubernetes/cloud.conf + mountPath: /etc/kubernetes/cloud.conf + readOnly: true + controllerManager: + extraArgs: + cloud-provider: openstack + cloud-config: /etc/kubernetes/cloud.conf + extraVolumes: + - name: cloud + hostPath: /etc/kubernetes/cloud.conf + mountPath: /etc/kubernetes/cloud.conf + readOnly: true + - name: cacerts + hostPath: /etc/certs/cacert + mountPath: /etc/certs/cacert + readOnly: true diff --git a/examples/controlplane/single-node/kustomization.yaml b/examples/controlplane/single-node/kustomization.yaml new file mode 100644 index 0000000000..44a9cc2831 --- /dev/null +++ b/examples/controlplane/single-node/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: ${CLUSTER_NAME} +resources: +- controlplane.yaml +configurations: +- kustomizeconfig.yaml diff --git a/examples/controlplane/single-node/kustomizeconfig.yaml b/examples/controlplane/single-node/kustomizeconfig.yaml new file mode 100644 index 0000000000..fa95d11679 --- /dev/null +++ b/examples/controlplane/single-node/kustomizeconfig.yaml @@ -0,0 +1,15 @@ +namespace: +- kind: Machine + group: cluster.x-k8s.io + version: v1alpha2 + path: spec/infrastructureRef/namespace + create: true +- kind: Machine + group: cluster.x-k8s.io + version: v1alpha2 + path: spec/bootstrap/configRef/namespace + create: true + +commonLabels: +- path: metadata/labels + create: true diff --git a/examples/generate.sh b/examples/generate.sh index 72657700af..40697ca2d7 100755 --- a/examples/generate.sh +++ b/examples/generate.sh @@ -18,7 +18,6 @@ set -o nounset # Directories. SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -OUTPUT_DIR=${OUTPUT_DIR:-${SOURCE_DIR}/_out} # Binaries ENVSUBST=${ENVSUBST:-envsubst} @@ -32,6 +31,7 @@ export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.15.0}" export CONTROL_PLANE_MACHINE_TYPE="${CONTROL_PLANE_MACHINE_TYPE:-m1.medium}" export NODE_MACHINE_TYPE="${CONTROL_PLANE_MACHINE_TYPE:-m1.medium}" export SSH_KEY_NAME="${SSH_KEY_NAME:-cluster-api-provider-openstack}" +export CONTROLPLANE="single-node" # Overwrite flag. OVERWRITE=0 @@ -42,7 +42,7 @@ while test $# -gt 0; do -h|--help) echo "$SCRIPT - generates input yaml files for Cluster API on OpenStack" echo " " - echo "$SCRIPT [options] [output folder]" + echo "$SCRIPT [options] [output folder] " echo " " echo "options:" echo "-h, --help show brief help" @@ -83,10 +83,27 @@ else exit 1 fi +# Check if output folder directory is provided if [[ -n "${3-}" ]] && [[ $3 != -* ]] && [[ $3 != --* ]]; then OUTPUT_DIR=$(echo $3 | tr '[:upper:]' '[:lower:]') else - echo "no output folder provided, use name '_out' by default" + echo "Error: No output folder provided" + echo "You must specify the output folder." + echo "" + exit 1 +fi + +# Check if correct controlplane preference is given +if [[ -n "${4-}" ]] && [[ $4 != -* ]] && [[ $4 != --* ]]; then + if [[ "$4" == "single-node" || "$4" == "multi-node" ]]; then + export CONTROLPLANE=$4 + else + echo "\"${4}\" is not a valid keyword. Use \"single-node\" or \"multi-node\" instead." + echo "" + exit 1 + fi +else + echo "Controlplane preference not given, generating samples for \"single-node\" by default" fi if [[ ${OVERWRITE} -ne 1 ]] && [[ -d "$OUTPUT_DIR" ]]; then @@ -101,7 +118,6 @@ if [[ ${yq_type} == *"Python script"* ]]; then exit 1 fi - # Outputs. COMPONENTS_CLUSTER_API_GENERATED_FILE=${SOURCE_DIR}/provider-components/provider-components-cluster-api.yaml COMPONENTS_KUBEADM_GENERATED_FILE=${SOURCE_DIR}/provider-components/provider-components-kubeadm.yaml @@ -190,11 +206,11 @@ else fi # Generate cluster resources. -kustomize build "${SOURCE_DIR}/cluster" | envsubst > "${CLUSTER_GENERATED_FILE}" +kustomize build "${SOURCE_DIR}/cluster/${CONTROLPLANE}" | envsubst > "${CLUSTER_GENERATED_FILE}" echo "Generated ${CLUSTER_GENERATED_FILE}" # Generate controlplane resources. -kustomize build "${SOURCE_DIR}/controlplane" | envsubst > "${CONTROLPLANE_GENERATED_FILE}" +kustomize build "${SOURCE_DIR}/controlplane/${CONTROLPLANE}" | envsubst > "${CONTROLPLANE_GENERATED_FILE}" echo "Generated ${CONTROLPLANE_GENERATED_FILE}" # Generate machinedeployment resources. diff --git a/examples/machinedeployment/machinedeployment.yaml b/examples/machinedeployment/machinedeployment.yaml index ae590d9800..333cf77bd4 100644 --- a/examples/machinedeployment/machinedeployment.yaml +++ b/examples/machinedeployment/machinedeployment.yaml @@ -49,6 +49,12 @@ spec: namespace: ${CLUSTER_NAME} flavor: m1.medium image: + networks: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} + subnets: + - filter: + name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} sshKeyName: cluster-api-provider-openstack --- apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2 From 868d4efc1a65aecc888a939d55c827f589cb5cd9 Mon Sep 17 00:00:00 2001 From: prankul88 Date: Mon, 21 Oct 2019 14:54:55 +0530 Subject: [PATCH 2/3] Update controlplane and machinedeployment.yaml --- .../controlplane/multi-node/controlplane.yaml | 18 ------------------ .../controlplane/single-node/controlplane.yaml | 6 ------ examples/generate.sh | 2 +- .../machinedeployment/machinedeployment.yaml | 6 ------ 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/examples/controlplane/multi-node/controlplane.yaml b/examples/controlplane/multi-node/controlplane.yaml index aba091eaea..e28d1a90e4 100644 --- a/examples/controlplane/multi-node/controlplane.yaml +++ b/examples/controlplane/multi-node/controlplane.yaml @@ -33,12 +33,6 @@ spec: image: sshKeyName: cluster-api-provider-openstack availabilityZone: nova - networks: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} - subnets: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} cloudName: $CLOUD cloudsSecret: name: cloud-config @@ -138,12 +132,6 @@ spec: image: sshKeyName: cluster-api-provider-openstack availabilityZone: nova - networks: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} - subnets: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} cloudName: $CLOUD cloudsSecret: name: cloud-config @@ -219,12 +207,6 @@ spec: image: sshKeyName: cluster-api-provider-openstack availabilityZone: nova - networks: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} - subnets: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} cloudName: $CLOUD cloudsSecret: name: cloud-config diff --git a/examples/controlplane/single-node/controlplane.yaml b/examples/controlplane/single-node/controlplane.yaml index 47398b494e..33f6a4f578 100644 --- a/examples/controlplane/single-node/controlplane.yaml +++ b/examples/controlplane/single-node/controlplane.yaml @@ -33,12 +33,6 @@ spec: image: sshKeyName: cluster-api-provider-openstack availabilityZone: nova - networks: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} - subnets: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} floatingIP: cloudName: $CLOUD cloudsSecret: diff --git a/examples/generate.sh b/examples/generate.sh index 40697ca2d7..43b714deb3 100755 --- a/examples/generate.sh +++ b/examples/generate.sh @@ -42,7 +42,7 @@ while test $# -gt 0; do -h|--help) echo "$SCRIPT - generates input yaml files for Cluster API on OpenStack" echo " " - echo "$SCRIPT [options] [output folder] " + echo "$SCRIPT [options] [single-node/multi-node]" echo " " echo "options:" echo "-h, --help show brief help" diff --git a/examples/machinedeployment/machinedeployment.yaml b/examples/machinedeployment/machinedeployment.yaml index 333cf77bd4..ae590d9800 100644 --- a/examples/machinedeployment/machinedeployment.yaml +++ b/examples/machinedeployment/machinedeployment.yaml @@ -49,12 +49,6 @@ spec: namespace: ${CLUSTER_NAME} flavor: m1.medium image: - networks: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} - subnets: - - filter: - name: k8s-clusterapi-cluster-${CLUSTER_NAME}-${CLUSTER_NAME} sshKeyName: cluster-api-provider-openstack --- apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2 From 84ec30dc018e6ceff352ae3e98e0b86349ce46f2 Mon Sep 17 00:00:00 2001 From: prankul88 Date: Mon, 21 Oct 2019 23:43:43 +0530 Subject: [PATCH 3/3] Update generate.sh with upstream Cluster-API repo --- examples/generate.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/generate.sh b/examples/generate.sh index 43b714deb3..311a5748c5 100755 --- a/examples/generate.sh +++ b/examples/generate.sh @@ -221,12 +221,24 @@ cp ${SOURCE_DIR}/addons.yaml "${ADDONS_GENERATED_FILE}" echo "Generated ${ADDONS_GENERATED_FILE}" # Generate Cluster API provider components file. -kustomize build "github.com/kubernetes-sigs/cluster-api/config/default/?ref=master" > "${COMPONENTS_CLUSTER_API_GENERATED_FILE}" -echo "Generated ${COMPONENTS_CLUSTER_API_GENERATED_FILE}" +CAPI_BRANCH=${CAPI_BRANCH:-"stable"} +if [[ ${CAPI_BRANCH} == "stable" ]]; then + curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.2.4/cluster-api-components.yaml > "${COMPONENTS_CLUSTER_API_GENERATED_FILE}" + echo "Downloaded ${COMPONENTS_CLUSTER_API_GENERATED_FILE} from cluster-api stable branch - v0.2.4" +else + kustomize build "github.com/kubernetes-sigs/cluster-api/config/default/?ref=${CAPI_BRANCH}" > "${COMPONENTS_CLUSTER_API_GENERATED_FILE}" + echo "Generated ${COMPONENTS_CLUSTER_API_GENERATED_FILE} from cluster-api - ${CAPI_BRANCH}" +fi # Generate Kubeadm Bootstrap Provider components file. -kustomize build "github.com/kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm//config/default/?ref=master" > "${COMPONENTS_KUBEADM_GENERATED_FILE}" -echo "Generated ${COMPONENTS_KUBEADM_GENERATED_FILE}" +CABPK_BRANCH=${CABPK_BRANCH:-"stable"} +if [[ ${CABPK_BRANCH} == "stable" ]]; then + curl -L https://github.com/kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm/releases/download/v0.1.2/bootstrap-components.yaml > "${COMPONENTS_KUBEADM_GENERATED_FILE}" + echo "Downloaded ${COMPONENTS_KUBEADM_GENERATED_FILE} from cluster-api-bootstrap-provider-kubeadm stable branch - v0.1.2" +else + kustomize build "github.com/kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm/config/default/?ref=${CABPK_BRANCH}" > "${COMPONENTS_KUBEADM_GENERATED_FILE}" + echo "Generated ${COMPONENTS_KUBEADM_GENERATED_FILE} from cluster-api-bootstrap-provider-kubeadm - ${CABPK_BRANCH}" +fi # Generate OpenStack Infrastructure Provider components file. kustomize build "${SOURCE_DIR}/../config/default" | envsubst > "${COMPONENTS_OPENSTACK_GENERATED_FILE}"