Skip to content

Commit 7914508

Browse files
author
Maciej Golaszewski
committed
remove environment variables from integration tests
KU-1226
1 parent 6389bd9 commit 7914508

File tree

7 files changed

+516
-159
lines changed

7 files changed

+516
-159
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ This project offers a cluster API bootstrap provider controller that manages the
99
### Prerequisites
1010

1111
* Install clusterctl following the [upstream instructions](https://cluster-api.sigs.k8s.io/user/quick-start.html#install-clusterctl)
12-
```bash
12+
```
1313
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.1.3/clusterctl-linux-amd64 -o clusterctl
1414
```
1515

1616
* Install a bootstrap Kubernetes cluster. To use MicroK8s as a bootstrap cluster:
17-
```bash
17+
```
1818
sudo snap install microk8s --classic
1919
sudo microk8s.config > ~/.kube/config
2020
sudo microk8s enable dns
@@ -24,7 +24,7 @@ sudo microk8s enable dns
2424

2525
To to configure clusterctl with the two MicroK8s providers edit `~/.cluster-api/clusterctl.yaml`
2626
and add the following:
27-
```yaml
27+
```
2828
providers:
2929
- name: "microk8s"
3030
url: "https://github.com/canonical/cluster-api-bootstrap-provider-microk8s/releases/latest/bootstrap-components.yaml"
@@ -47,18 +47,18 @@ Alternatively, you can build the providers manually as described in the followin
4747
### Building from source
4848

4949
* Install the cluster provider of your choice. Have a look at the [cluster API book](https://cluster-api.sigs.k8s.io/user/quick-start.html#initialization-for-common-providers) for your options at this step. You should deploy only the infrastructure controller leaving the bootstrap and control plane ones empty. For example assuming we want to provision a MicroK8s cluster on AWS:
50-
```bash
50+
```
5151
clusterctl init --infrastructure aws --bootstrap "-" --control-plane "-"
5252
```
5353

5454
* Clone the two cluster API MicroK8s specific repositories and start the controllers on two separate terminals:
55-
```bash
55+
```
5656
cd $GOPATH/src/github.com/canonical/cluster-api-bootstrap-provider-microk8s/
5757
make install
5858
make run
5959
```
6060
And:
61-
```bash
61+
```
6262
cd $GOPATH/src/github.com/canonical/cluster-api-control-plane-provider-microk8s/
6363
make install
6464
make run
@@ -68,7 +68,7 @@ make run
6868

6969
As soon as the bootstrap and control-plane controllers are up and running you can apply the cluster manifests describing the desired specs of the cluster you want to provision. Each machine is associated with a MicroK8sConfig through which you can set the cluster's properties. Please review the available options in [the respective definitions file](./apis/v1beta1/microk8sconfig_types.go). You may also find useful the example manifests found under the [examples](./examples/) directory. Note that the configuration structure followed is similar to the the one of kubeadm, in the MicroK8sConfig you will find a CLusterConfiguration and an InitConfiguration sections. When targeting a specific infrastructure you should be aware of which ports are used by MicroK8s and allow them in the network security groups on your deployment.
7070

71-
Two workload cluster templates are available under the [templates](./templates/) folder, which are actively used to validate releases:
71+
Two workload cluster templates are available under the [templates](./templates) folder, which are actively used to validate releases:
7272
- [AWS](./templates/cluster-template-aws.yaml), using the [AWS Infrastructure Provider](https://github.com/kubernetes-sigs/cluster-api-provider-aws)
7373
- [OpenStack](./templates/cluster-template-openstack.yaml), using the [OpenStack Infrastructure Provider](https://github.com/kubernetes-sigs/cluster-api-provider-openstack)
7474

integration/README.md

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,10 @@
44

55
The integration/e2e tests have the following prerequisites:
66

7-
* an environment variable `CLUSTER_MANIFEST_FILE` pointing to the cluster manifest. Cluster manifests can be produced with the help of the templates found under [`templates`](../templates). For example:
8-
```bash
9-
export AWS_REGION=us-east-1
10-
export AWS_SSH_KEY_NAME=capi
11-
export CONTROL_PLANE_MACHINE_COUNT=3
12-
export WORKER_MACHINE_COUNT=3
13-
export AWS_CREATE_BASTION=false
14-
export AWS_PUBLIC_IP=false
15-
export AWS_CONTROL_PLANE_MACHINE_FLAVOR=t3.large
16-
export AWS_NODE_MACHINE_FLAVOR=t3.large
17-
export CLUSTER_NAME=test-ci-cluster
18-
clusterctl generate cluster ${CLUSTER_NAME} --from "templates/cluster-template-aws.yaml" --kubernetes-version 1.27.0 > cluster.yaml
19-
export CLUSTER_MANIFEST_FILE=$PWD/cluster.yaml
20-
```
21-
> NOTE: AWS_SSH_KEY_NAME is name of ssh key in AWS that you are plan to use, if you don't have one yet refer
22-
> to capi on [aws prerequisites documentation](https://cluster-api-aws.sigs.k8s.io/topics/using-clusterawsadm-to-fulfill-prerequisites#ssh-key-pair)
23-
* Additional environment variables when testing cluster upgrades:
24-
```bash
25-
export CAPI_UPGRADE_VERSION=v1.28.0
26-
export CAPI_UPGRADE_MD_NAME=${CLUSTER_NAME}-md-0
27-
export CAPI_UPGRADE_MD_TYPE=machinedeployments.cluster.x-k8s.io
28-
export CAPI_UPGRADE_CP_NAME=${CLUSTER_NAME}-control-plane
29-
export CAPI_UPGRADE_CP_TYPE=microk8scontrolplanes.controlplane.cluster.x-k8s.io
30-
# Change the control plane and worker machine count to desired values for in-place upgrades tests and create a new cluster manifest.
31-
CONTROL_PLANE_MACHINE_COUNT=1
32-
WORKER_MACHINE_COUNT=1
33-
clusterctl generate cluster ${CLUSTER_NAME} --from "templates/cluster-template-aws.yaml" --kubernetes-version 1.27.0 > cluster-inplace.yaml
34-
export CLUSTER_INPLACE_MANIFEST_FILE=$PWD/cluster-inplace.yaml
35-
```
36-
37-
* Additional environment variables when testing disable default CNI flag:
38-
```bash
39-
export DISABLE_DEFAULT_CNI=true
40-
export POST_RUN_COMMANDS='["helm install cilium cilium/cilium --namespace kube-system --set cni.confPath=/var/snap/microk8s/current/args/cni-network --set cni.binPath=/var/snap/microk8s/current/opt/cni/bin --set daemon.runPath=/var/snap/microk8s/current/var/run/cilium --set operator.replicas=1 --set ipam.operator.clusterPoolIPv4PodCIDRList=\"10.1.0.0/16\" --set nodePort.enabled=true"]' # install Calico in place default CNI
41-
clusterctl generate cluster ${CLUSTER_NAME} --from "templates/cluster-template-aws.yaml" --kubernetes-version 1.27.0 > cluster_disable_default_cni.yaml
42-
export CLUSTER_DISABLE_DEFAULT_CNI_MANIFEST_FILE=$PWD/cluster_disable_default_cni.yaml
43-
```
7+
* make sure to have ssh key in aws `capi`in `us-east-1 region` if you do not have key refer
8+
to CAPI on [AWS prerequisites documentation](https://cluster-api-aws.sigs.k8s.io/topics/using-clusterawsadm-to-fulfill-prerequisites#ssh-key-pair)
449

45-
* `clusterctl` available in the PATH
46-
47-
* `kubectl` available in the PATH
10+
* to run tests locally you will need to have on path fallowing programs `clusterctl`, `kubectl`, `helm`
4811

4912
* a management cluster initialised via `clusterctl` with the infrastructure targeted as well as the version of the MicroK8s providers we want to be tested
5013

@@ -77,7 +40,7 @@ microk8s config > ~/.kube/config
7740
Visit [here](https://cluster-api.sigs.k8s.io/user/quick-start.html#initialization-for-common-providers) for a list of common infrastructure providers.
7841

7942
```bash
80-
clusterctl init --infrastructure <infra> --bootstrap - --control-plane -
43+
clusterctl init --infrastructure <infra> --bootstrap - --control-plane -
8144
```
8245

8346
#### Build Docker images and release manifests from the checked out source code
@@ -103,6 +66,9 @@ sed "s,docker.io/cdkbot/capi-control-plane-provider-microk8s:latest,docker.io/<u
10366
```bash
10467
kubectl apply -f bootstrap/bootstrap-components.yaml -f control-plane/control-plane-components.yaml
10568
```
69+
### Cluster definitions for e2e
70+
71+
Cluster definition are stored in [`manifests`](./cluster-manifests) directory.
10672

10773
#### Trigger the e2e tests
10874

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: test-ci-cluster
5+
namespace: default
6+
spec:
7+
controlPlaneRef:
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
9+
kind: MicroK8sControlPlane
10+
name: test-ci-cluster-control-plane
11+
infrastructureRef:
12+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
13+
kind: AWSCluster
14+
name: test-ci-cluster
15+
---
16+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
17+
kind: AWSCluster
18+
metadata:
19+
name: test-ci-cluster
20+
namespace: default
21+
spec:
22+
bastion:
23+
enabled: false
24+
region: us-east-1
25+
sshKeyName: capi
26+
---
27+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
28+
kind: MicroK8sControlPlane
29+
metadata:
30+
name: test-ci-cluster-control-plane
31+
namespace: default
32+
spec:
33+
controlPlaneConfig:
34+
clusterConfiguration:
35+
portCompatibilityRemap: true
36+
initConfiguration:
37+
IPinIP: true
38+
addons:
39+
- dns
40+
- ingress
41+
confinement: classic
42+
disableDefaultCNI: true
43+
joinTokenTTLInSecs: 900000
44+
riskLevel: stable
45+
machineTemplate:
46+
infrastructureTemplate:
47+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
48+
kind: AWSMachineTemplate
49+
name: test-ci-cluster-control-plane
50+
replicas: 1
51+
upgradeStrategy: SmartUpgrade
52+
version: v1.27.0
53+
---
54+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
55+
kind: AWSMachineTemplate
56+
metadata:
57+
name: test-ci-cluster-control-plane
58+
namespace: default
59+
spec:
60+
template:
61+
spec:
62+
iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io
63+
instanceType: t3.large
64+
publicIP: false
65+
sshKeyName: capi
66+
---
67+
apiVersion: cluster.x-k8s.io/v1beta1
68+
kind: MachineDeployment
69+
metadata:
70+
name: test-ci-cluster-md-0
71+
namespace: default
72+
spec:
73+
clusterName: test-ci-cluster
74+
replicas: 1
75+
selector:
76+
matchLabels: null
77+
template:
78+
spec:
79+
bootstrap:
80+
configRef:
81+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
82+
kind: MicroK8sConfigTemplate
83+
name: test-ci-cluster-md-0
84+
clusterName: test-ci-cluster
85+
infrastructureRef:
86+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
87+
kind: AWSMachineTemplate
88+
name: test-ci-cluster-md-0
89+
version: 1.27.0
90+
---
91+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
92+
kind: AWSMachineTemplate
93+
metadata:
94+
name: test-ci-cluster-md-0
95+
namespace: default
96+
spec:
97+
template:
98+
spec:
99+
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
100+
instanceType: t3.large
101+
publicIP: false
102+
sshKeyName: capi
103+
---
104+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
105+
kind: MicroK8sConfigTemplate
106+
metadata:
107+
name: test-ci-cluster-md-0
108+
namespace: default
109+
spec:
110+
template:
111+
spec:
112+
clusterConfiguration:
113+
portCompatibilityRemap: true
114+
initConfiguration:
115+
confinement: classic
116+
disableDefaultCNI: true
117+
riskLevel: stable
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: test-ci-cluster
5+
namespace: default
6+
spec:
7+
controlPlaneRef:
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
9+
kind: MicroK8sControlPlane
10+
name: test-ci-cluster-control-plane
11+
infrastructureRef:
12+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
13+
kind: AWSCluster
14+
name: test-ci-cluster
15+
---
16+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
17+
kind: AWSCluster
18+
metadata:
19+
name: test-ci-cluster
20+
namespace: default
21+
spec:
22+
bastion:
23+
enabled: false
24+
region: us-east-1
25+
sshKeyName: capi
26+
---
27+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
28+
kind: MicroK8sControlPlane
29+
metadata:
30+
name: test-ci-cluster-control-plane
31+
namespace: default
32+
spec:
33+
controlPlaneConfig:
34+
clusterConfiguration:
35+
portCompatibilityRemap: true
36+
initConfiguration:
37+
IPinIP: true
38+
addons:
39+
- dns
40+
- ingress
41+
confinement: classic
42+
disableDefaultCNI: false
43+
joinTokenTTLInSecs: 900000
44+
riskLevel: stable
45+
machineTemplate:
46+
infrastructureTemplate:
47+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
48+
kind: AWSMachineTemplate
49+
name: test-ci-cluster-control-plane
50+
replicas: 1
51+
upgradeStrategy: SmartUpgrade
52+
version: v1.27.0
53+
---
54+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
55+
kind: AWSMachineTemplate
56+
metadata:
57+
name: test-ci-cluster-control-plane
58+
namespace: default
59+
spec:
60+
template:
61+
spec:
62+
iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io
63+
instanceType: t3.large
64+
publicIP: false
65+
sshKeyName: capi
66+
---
67+
apiVersion: cluster.x-k8s.io/v1beta1
68+
kind: MachineDeployment
69+
metadata:
70+
name: test-ci-cluster-md-0
71+
namespace: default
72+
spec:
73+
clusterName: test-ci-cluster
74+
replicas: 1
75+
selector:
76+
matchLabels: null
77+
template:
78+
spec:
79+
bootstrap:
80+
configRef:
81+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
82+
kind: MicroK8sConfigTemplate
83+
name: test-ci-cluster-md-0
84+
clusterName: test-ci-cluster
85+
infrastructureRef:
86+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
87+
kind: AWSMachineTemplate
88+
name: test-ci-cluster-md-0
89+
version: 1.27.0
90+
---
91+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
92+
kind: AWSMachineTemplate
93+
metadata:
94+
name: test-ci-cluster-md-0
95+
namespace: default
96+
spec:
97+
template:
98+
spec:
99+
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
100+
instanceType: t3.large
101+
publicIP: false
102+
sshKeyName: capi
103+
---
104+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
105+
kind: MicroK8sConfigTemplate
106+
metadata:
107+
name: test-ci-cluster-md-0
108+
namespace: default
109+
spec:
110+
template:
111+
spec:
112+
clusterConfiguration:
113+
portCompatibilityRemap: true
114+
initConfiguration:
115+
confinement: classic
116+
disableDefaultCNI: false
117+
riskLevel: stable

0 commit comments

Comments
 (0)