This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
tasks.yaml
216 lines (191 loc) · 7.44 KB
/
tasks.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# yaml-language-server: $schema=https://raw.githubusercontent.com/defenseunicorns/uds-cli/main/tasks.schema.json
variables:
- name: ZARF_VERSION
default: v0.32.2
- name: DUBBD_K3D_VERSION
default: 0.18.0
- name: METALLB_VERSION
default: 0.0.5
tasks:
########################################################################
# Macro Section
########################################################################
- name: all
actions:
- task: build-all
- task: cluster-reset
- task: deploy-all
- name: rebuild
actions:
- task: clean
- task: build-all
- name: cluster-reset
actions:
- task: cluster-destroy
- task: cluster-create
- task: cluster-calico
- name: build-all
actions:
- task: build
- task: build-zarf
- task: build-zarf-init
- task: build-metallb
- task: build-dubbd-k3d
- task: build-test-pkg-deps
- task: build-uds-capability-gitlab
- name: ci-build-all
actions:
- task: build
- task: build-zarf
- task: build-zarf-init
- task: build-dubbd-k3d
- task: build-test-pkg-deps
- task: build-uds-capability-gitlab
- name: deploy-all
actions:
- task: deploy-init
- task: deploy-metallb
- task: deploy-dubbd-k3d
- task: deploy-test-pkg-deps
- task: deploy-uds-capability-gitlab
- name: ci-deploy-all
actions:
- task: deploy-init
- task: deploy-dubbd-k3d
- task: deploy-test-pkg-deps
- task: deploy-uds-capability-gitlab
########################################################################
# Get OS and CPU Architecture
########################################################################
- name: set-os-arch
actions:
- cmd: |
ARCH=$(uname -m)
[ "$ARCH" = "x86_64" ] && ARCH="amd64"
echo $ARCH
setVariables:
- name: ARCH
sensitive: false
- cmd: uname -s
setVariables:
- name: PLATFORM
sensitive: false
########################################################################
# Set Network Range
########################################################################
- name: set-network-range
actions:
- cmd: |
NETWORK_BASE=$(kubectl get nodes -o=jsonpath='{.items[0].metadata.annotations.k3s\.io/internal-ip}' | cut -d '.' --fields '1 2 3')
NETWORK_RANGE_START="${NETWORK_BASE}.200"
echo $NETWORK_RANGE_START
setVariables:
- name: NETWORK_RANGE_START
sensitive: false
- cmd: |
NETWORK_BASE=$(kubectl get nodes -o=jsonpath='{.items[0].metadata.annotations.k3s\.io/internal-ip}' | cut -d '.' --fields '1 2 3')
NETWORK_RANGE_END="${NETWORK_BASE}.210"
echo $NETWORK_RANGE_END
setVariables:
- name: NETWORK_RANGE_END
sensitive: false
########################################################################
# Cluster Section
########################################################################
- name: cluster-create
actions:
- cmd: |
K3D_FIX_MOUNTS=1 k3d cluster create k3d-test-cluster --config utils/k3d/k3d-config.yaml
k3d kubeconfig merge k3d-test-cluster -o /home/${USER}/cluster-kubeconfig.yaml
- name: cluster-calico
actions:
- cmd: |
echo "Installing Calico..."
kubectl apply --wait=true -f utils/calico/calico.yaml 2>&1 >/dev/null
echo "Waiting for Calico to be ready..."
kubectl rollout status deployment/calico-kube-controllers -n kube-system --watch --timeout=90s 2>&1 >/dev/null
kubectl rollout status daemonset/calico-node -n kube-system --watch --timeout=90s 2>&1 >/dev/null
kubectl wait --for=condition=Ready pods --all --all-namespaces 2>&1 >/dev/null
- name: cluster-destroy
actions:
- cmd: k3d cluster delete k3d-test-cluster
########################################################################
# Build Section
########################################################################
- name: build
actions:
- cmd: mkdir -p build
- cmd: |
echo "no_progress: true" > zarf-config.yaml
dir: build
- name: clean
actions:
- cmd: rm -rf ./build
- name: build-zarf
actions:
- task: set-os-arch
- cmd: |
if [ -f ./zarf ] && [ "$(./zarf version)" = "${ZARF_VERSION}" ] ; then exit 0; fi
echo "Downloading zarf"
curl -sL https://github.com/defenseunicorns/zarf/releases/download/${ZARF_VERSION}/zarf_${ZARF_VERSION}_${PLATFORM}_${ARCH} -o ./zarf
chmod +x ./zarf
dir: build
- name: build-zarf-init
actions:
- cmd: |
if [ -f build/zarf-init-amd64-${ZARF_VERSION}.tar.zst ] ; then exit 0; fi
echo "Downloading zarf-init-amd64-${ZARF_VERSION}.tar.zst"
curl -sL https://github.com/defenseunicorns/zarf/releases/download/${ZARF_VERSION}/zarf-init-amd64-${ZARF_VERSION}.tar.zst -o ./zarf-init-amd64-${ZARF_VERSION}.tar.zst
dir: build
- name: build-metallb
actions:
- cmd: ./zarf package pull oci://ghcr.io/defenseunicorns/packages/metallb:${METALLB_VERSION}-amd64
dir: build
- name: build-dubbd-k3d
actions:
- cmd: |
if [ -f build/zarf-package-dubbd-k3d-amd64-${DUBBD_K3D_VERSION}.tar.zst ] ; then exit 0; fi
./zarf package pull oci://ghcr.io/defenseunicorns/packages/dubbd-k3d:${DUBBD_K3D_VERSION} -a amd64 --oci-concurrency 12
dir: build
- name: build-test-pkg-deps
actions:
- cmd: |
./zarf package create ../utils/pkg-deps/namespaces/ --skip-sbom --confirm
./zarf package create ../utils/pkg-deps/gitlab/postgres/ --skip-sbom --confirm
./zarf package create ../utils/pkg-deps/gitlab/redis/ --skip-sbom --confirm
./zarf package create ../utils/pkg-deps/gitlab/minio/ --skip-sbom --confirm
./zarf package create ../utils/pkg-deps/gitlab/kyverno-exceptions/ --skip-sbom --confirm
dir: build
- name: build-uds-capability-gitlab
actions:
- cmd: ./zarf package create ../ --skip-sbom --confirm
dir: build
########################################################################
# Deploy Section
########################################################################
- name: deploy-init
actions:
- cmd: ./zarf init --confirm --components=git-server
dir: build
- name: deploy-metallb
actions:
- task: set-network-range
- cmd: ./zarf package deploy zarf-package-metallb-amd64-${METALLB_VERSION}.tar.zst --set IP_ADDRESS_POOL=${NETWORK_RANGE_START}-${NETWORK_RANGE_END} --confirm
dir: build
- name: deploy-dubbd-k3d
actions:
- cmd: ./zarf package deploy zarf-package-dubbd-k3d-amd64-${DUBBD_K3D_VERSION}.tar.zst --confirm
dir: build
- name: deploy-test-pkg-deps
actions:
- cmd: |
./zarf package deploy zarf-package-gitlab-namespaces-* --confirm
./zarf package deploy zarf-package-gitlab-postgres-* --confirm
./zarf package deploy zarf-package-gitlab-redis-* --confirm
./zarf package deploy zarf-package-gitlab-minio-* --confirm
./zarf package deploy zarf-package-gitlab-kyverno-* --confirm
dir: build
- name: deploy-uds-capability-gitlab
actions:
- cmd: ./zarf package deploy zarf-package-gitlab-amd*.tar.zst --confirm
dir: build