-
Notifications
You must be signed in to change notification settings - Fork 18
180 lines (153 loc) · 6.17 KB
/
pre-submit.yaml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Pre Submit
on:
push:
branches:
- main
- release-*
pull_request:
branches:
- main
- release-*
jobs:
build-and-unit-test:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Build
run: make manager
- name: Verify no bundle changes and run unit-tests
run: make manifests bundle-k8s bundle-reset test
- name: Test container build K8s
run: make container-build-k8s
- name: Test container build OCP
run: make container-build-ocp
e2e-k8s:
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
IMAGE_REGISTRY: kind-registry:5000
DEPLOY_NAMESPACE: k8s-test
# see https://github.com/kubernetes-sigs/kind/tags
KIND_VERSION: v0.20.0
# see https://hub.docker.com/r/kindest/node/tags for available versions!
K8S_VERSION: v1.27.3
# https://github.com/operator-framework/operator-lifecycle-manager/releases
OLM_VERSION: v0.26.0
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Configure insecure registry
run: |
#sudo cat /etc/docker/daemon.json
# allow insecure registry but keep original config!
sudo bash -c "cat <<EOF >/etc/docker/daemon.json
{
\"exec-opts\": [\"native.cgroupdriver=cgroupfs\"],
\"cgroup-parent\": \"/actions_job\",
\"insecure-registries\" : [\"${IMAGE_REGISTRY}\"]
}
EOF"
sudo cat /etc/docker/daemon.json
sudo systemctl restart docker
# same for podman
sudo bash -c "cat <<EOF >/etc/containers/registries.conf
[[registry]]
location=\"${IMAGE_REGISTRY}\"
insecure=true
EOF"
sudo cat /etc/containers/registries.conf
- name: Start kind cluster
uses: container-tools/kind-action@v2
with:
version: ${{env.KIND_VERSION}}
config: ./hack/kind-config.yaml
node_image: kindest/node:${{env.K8S_VERSION}}
kubectl_version: ${{env.K8S_VERSION}}
registry: true
- name: Cluster info
run: |
kubectl version -o=yaml
kubectl cluster-info
kubectl get nodes -o=wide
- name: Install OLM
run: |
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/install.sh | bash -s ${OLM_VERSION}
- name: Build NHC
run: |
export NHC_SKIP_TEST=true
make container-build-k8s container-push
# make operator-sdk findable...
cp ./bin/operator-sdk /usr/local/bin/
- name: Deploy NHC + SNR
run: |
kubectl create ns ${DEPLOY_NAMESPACE}
# deploy SNR first
# HEADS UP: using a custom build of SNR here which uses `systemctl start kubelet` as "reboot" command,
# everything else does not work with kind.
# See https://github.com/slintes/self-node-remediation/commit/a8aa0f73a240509cbd446fae048b15ed11a20eea
operator-sdk run bundle -n ${DEPLOY_NAMESPACE} quay.io/slintes/self-node-remediation-operator-bundle:v0.1.0-start-kubelet
# deploy NHC
operator-sdk run bundle -n ${DEPLOY_NAMESPACE} --use-http ${IMAGE_REGISTRY}/node-healthcheck-operator-bundle:latest
# wait a bit for OLM creating CSV etc
sleep 1m
- name: OLM status
if: ${{ always() }}
run: |
kubectl get -A OperatorGroup -o wide
kubectl get -A CatalogSource -o wide
kubectl get -A Subscription -o wide
kubectl get -A ClusterServiceVersion -o wide
kubectl get -A InstallPlan -o wide
- name: Wait for deployments
run: |
kubectl wait deployment -n ${DEPLOY_NAMESPACE} self-node-remediation-controller-manager --for condition=Available=True --timeout=300s
# give SNR some time to create the DS
sleep 30s
kubectl rollout status daemonset -n ${DEPLOY_NAMESPACE} self-node-remediation-ds --timeout 300s
kubectl wait deployment -n ${DEPLOY_NAMESPACE} node-healthcheck-controller-manager --for condition=Available=True --timeout=300s
- name: Deployment status
if: ${{ always() }}
run: |
kubectl -n ${DEPLOY_NAMESPACE} get deployments,daemonsets,pods -o=wide
- name: Run NHC e2e
run: |
echo "running e2e test"
OPERATOR_NS=${DEPLOY_NAMESPACE} SNR_STRATEGY=OutOfServiceTaint LABEL_FILTER="!OCP-ONLY" make test-e2e
echo "finished e2e test"
- name: Debug
if: ${{ failure() }}
run: |
# debug NHC
echo "Debugging NHC"
kubectl describe deployment -n ${DEPLOY_NAMESPACE} node-healthcheck-controller-manager
echo "\n\n"
kubectl describe pod -n ${DEPLOY_NAMESPACE} --selector=app.kubernetes.io/name=node-healthcheck-operator,app.kubernetes.io/component=controller-manager
echo "\n\n"
kubectl logs -n ${DEPLOY_NAMESPACE} -c manager --selector=app.kubernetes.io/name=node-healthcheck-operator,app.kubernetes.io/component=controller-manager --tail -1
echo "\n\n"
echo "Debugging SNR operator"
kubectl describe deployment -n ${DEPLOY_NAMESPACE} self-node-remediation-controller-manager
echo "\n\n"
kubectl describe pod -n ${DEPLOY_NAMESPACE} --selector=self-node-remediation-operator=,control-plane=controller-manager
echo "\n\n"
kubectl logs -n ${DEPLOY_NAMESPACE} -c manager --selector=self-node-remediation-operator=,control-plane=controller-manager --tail -1
echo "\n\n"
echo "Debugging SNR agents"
kubectl describe daemonset -n ${DEPLOY_NAMESPACE} self-node-remediation-ds
echo "\n\n"
kubectl describe pod -n ${DEPLOY_NAMESPACE} --selector=app.kubernetes.io/name=self-node-remediation,app.kubernetes.io/component=agent
echo "\n\n"
kubectl logs -n ${DEPLOY_NAMESPACE} --selector=app.kubernetes.io/name=self-node-remediation,app.kubernetes.io/component=agent --tail -1