-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yaml
More file actions
106 lines (98 loc) · 4.28 KB
/
action.yaml
File metadata and controls
106 lines (98 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: "E2E Workflow"
description: "Run Greenhouse E2E test against a Kubernetes cluster"
inputs:
admin-cluster-name:
description: "The kind cluster name"
required: false
default: "greenhouse-admin"
remote-cluster-name:
description: "The kind cluster name"
required: false
default: "greenhouse-remote"
remote-k8s-version:
description: "The Kubernetes version used to spin up remote cluster"
required: true
admin-k8s-version:
description: "The Kubernetes version used to spin up admin cluster"
required: true
admin-config:
description: "The kind cluster configuration file for admin cluster"
required: false
default: ""
remote-config:
description: "The kind cluster configuration file for remote cluster"
required: false
default: ""
scenario:
description: "The E2E scenario to run"
required: true
outputs:
result:
description: "The path to the E2E test results"
value: ${{ steps.e2e.outputs.result }}
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: cloudoperators/greenhouse
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: 'go.mod'
# Create the admin cluster with latest kubernetes version
- name: Create Admin Cluster
uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab # v1.13.0
with:
version: 'v0.31.0'
cluster_name: ${{ inputs.admin-cluster-name }}
node_image: 'kindest/node:${{ inputs.admin-k8s-version }}'
config: ${{ inputs.admin-config }}
# after admin cluster setup, extract the apiServer CA from kube-root-ca.crt configmap (needed for remote cluster OIDC setup)
# and create a clusterrolebinding to allow unauthenticated access to the admin cluster for OIDC discovery
- name: Post Setup Admin Cluster
shell: bash
env:
KUBECONFIG: ${{ runner.temp }}/admin-kubeconfig.yaml
run: |
mkdir -p bin
kind get kubeconfig --name ${{ inputs.admin-cluster-name }} > ${{ runner.temp }}/admin-kubeconfig.yaml
kubectl get cm kube-root-ca.crt -n default -o json | jq -r '.data."ca.crt"' > bin/greenhouse-admin-ca.crt
cp ./dev-env/structured-auth.yaml ./bin/structured-auth.yaml
yq eval --inplace '.jwt[0].issuer.certificateAuthority = load_str("./bin/greenhouse-admin-ca.crt")' ./bin/structured-auth.yaml
kubectl create clusterrolebinding "oidc-reviewer-binding" \
--clusterrole="system:service-account-issuer-discovery" \
--group="system:unauthenticated"
# Create the remote cluster with kubernetes version from the matrix
- name: Create Remote Cluster
uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab # v1.13.0
with:
version: 'v0.31.0'
node_image: 'kindest/node:${{ inputs.remote-k8s-version }}'
cluster_name: ${{ inputs.remote-cluster-name }}
config: ${{ inputs.remote-config }}
# build CLI, setup e2e environment and prepare kubeconfigs
- name: "Prepare E2E Config"
shell: bash
id: config
run: |
make setup-e2e
echo "admin_config=$GITHUB_WORKSPACE/bin/${{inputs.admin-cluster-name}}.kubeconfig" >> $GITHUB_OUTPUT
echo "remote_config=$GITHUB_WORKSPACE/bin/${{inputs.remote-cluster-name}}.kubeconfig" >> $GITHUB_OUTPUT
echo "remote_int_config=$GITHUB_WORKSPACE/bin/${{inputs.remote-cluster-name}}-int.kubeconfig" >> $GITHUB_OUTPUT
# run the e2e tests with the scenario from the matrix
- name: "E2E Run"
shell: bash
id: e2e
env:
SCENARIO: ${{ inputs.scenario }}
EXECUTION_ENV: gh-actions
GREENHOUSE_ADMIN_KUBECONFIG: ${{ steps.config.outputs.admin_config }}
GREENHOUSE_REMOTE_KUBECONFIG: ${{ steps.config.outputs.remote_config }}
GREENHOUSE_REMOTE_INT_KUBECONFIG: ${{ steps.config.outputs.remote_int_config }}
CONTROLLER_LOGS_PATH: ${{github.workspace}}/bin/${{inputs.scenario}}-${{inputs.k8s-version}}.txt
E2E_REPORT_PATH: ${{github.workspace}}/bin/${{inputs.scenario}}-${{matrix.k8s-version}}.json
run: |
echo "result=$CONTROLLER_LOGS_PATH" >> $GITHUB_OUTPUT
make e2e