@@ -39,329 +39,109 @@ tasks:
3939 default :
4040 desc : Show available tasks
4141 cmds :
42- - task -s - -list
42+ - task --list
4343
4444 cluster-create :
4545 desc : Create a test cluster using Replicated Compatibility Matrix (use EMBEDDED=true for embedded clusters)
46- run : once
47- silent : false
48- vars :
49- EMBEDDED : ' {{.EMBEDDED | default "false"}}'
50- LICENSE_ID : ' {{if eq .EMBEDDED "true"}}{{.LICENSE_ID | default "2cmqT1dBVHZ3aSH21kPxWtgoYGr"}}{{end}}'
51- TIMEOUT : ' {{if eq .EMBEDDED "true"}}420{{else}}300{{end}}'
52- status :
53- - replicated cluster ls --output json | jq -e '.[] | select(.name == "{{.CLUSTER_NAME}}")' > /dev/null
5446 cmds :
55- - |
56- if [ "{{.EMBEDDED}}" = "true" ]; then
57- echo "Creating embedded cluster {{.CLUSTER_NAME}} with license ID {{.LICENSE_ID}}..."
58- replicated cluster create --distribution embedded-cluster --name {{.CLUSTER_NAME}} --license-id {{.LICENSE_ID}}
59- else
60- echo "Creating cluster {{.CLUSTER_NAME}} with distribution {{.DISTRIBUTION}}..."
61- replicated cluster create --name {{.CLUSTER_NAME}} --distribution {{.DISTRIBUTION}} --version {{.K8S_VERSION}} --disk {{.DISK_SIZE}} --instance-type {{.INSTANCE_TYPE}}
62- fi
63- - task : utils:wait-for-cluster
47+ - task : dev:shell
6448 vars :
65- TIMEOUT : " {{.TIMEOUT}} "
49+ CMD : " task cluster-create "
6650
6751 list-cluster :
6852 desc : List the cluster
69- silent : false
7053 cmds :
71- - |
72- CLUSTER_ID=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .id')
73- EXPIRES=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .expires_at')
74- echo "{{.CLUSTER_NAME}} Cluster ID: ($CLUSTER_ID) Expires: ($EXPIRES)"
54+ - task : dev:shell
55+ vars :
56+ CMD : " task list-cluster"
7557
7658 test :
7759 desc : Run a basic test suite
78- silent : false
7960 cmds :
80- - echo "Running basic tests..."
81- - echo "This is a placeholder for actual tests"
82- - sleep 5
83- - echo "Tests completed!"
84-
61+ - task : dev:shell
62+ vars :
63+ CMD : " task test"
8564
8665 verify-kubeconfig :
8766 desc : Verify kubeconfig
88- silent : false
89- run : once
9067 cmds :
91- - |
92- if [ -f {{.KUBECONFIG_FILE}} ]; then
93- echo "Getting Cluster ID From Replicated Cluster list"
94- CLUSTER_ID=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .id')
95- echo "Getting Cluster ID From Kubeconfig"
96- CLUSTER_ID_KUBECONFIG=$(grep "current-context:" {{.KUBECONFIG_FILE}} | cut -d'-' -f3)
97- if [ "$CLUSTER_ID" != "$CLUSTER_ID_KUBECONFIG" ]; then
98- echo "{{.CLUSTER_NAME}} Cluster ID between Replicated ($CLUSTER_ID) and Kubeconfig ($CLUSTER_ID_KUBECONFIG) mismatch"
99- echo "Removing old kubeconfig file"
100- rm -f {{.KUBECONFIG_FILE}}
101- fi
102- fi
68+ - task : dev:shell
69+ vars :
70+ CMD : " task verify-kubeconfig"
10371
10472 setup-kubeconfig :
10573 desc : Get kubeconfig and prepare cluster for application deployment
106- silent : false
107- run : once
10874 cmds :
109- - task : utils:get-kubeconfig
110- - task : utils:remove-k3s-traefik
111- status :
112- - |
113- # Check if kubeconfig exists
114- test -f {{.KUBECONFIG_FILE}} && \
115- # For k3s, also check if traefik is removed
116- if [ "{{.DISTRIBUTION}}" = "k3s" ]; then
117- KUBECONFIG={{.KUBECONFIG_FILE}} helm list -n kube-system -o json | \
118- jq -e 'map(select(.name == "traefik" or .name == "traefik-crd")) | length == 0' >/dev/null
119- else
120- true
121- fi
122- deps :
123- - cluster-create
124- - verify-kubeconfig
75+ - task : dev:shell
76+ vars :
77+ CMD : " task setup-kubeconfig"
12578
12679 dependencies-update :
12780 desc : Update Helm dependencies for all charts
128- silent : false
12981 cmds :
130- - echo "Updating Helm dependencies for all charts..."
131- - |
132- # Find all charts and update their dependencies
133- for chart_dir in $(find . -maxdepth 2 -name "Chart.yaml" | xargs dirname); do
134- echo "Updating dependency $chart_dir"
135- helm dependency update "$chart_dir"
136- done
137- - echo "All dependencies updated!"
82+ - task : dev:shell
83+ vars :
84+ CMD : " task dependencies-update"
13885
13986 ports-expose :
14087 desc : Expose configured ports and capture exposed URLs
141- silent : false
142- run : once
143- status :
144- - |
145- CLUSTER_ID=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .id')
146- if [ -z "$CLUSTER_ID" ]; then
147- exit 1
148- fi
149-
150- # Check if all ports are already exposed
151- expected_count={{len .EXPOSE_PORTS}}
152- port_checks=""
153- {{range $i, $port := .EXPOSE_PORTS}}
154- port_checks="${port_checks}(.upstream_port == {{$port.port}} and .exposed_ports[0].protocol == \"{{$port.protocol}}\") or "
155- {{end}}
156- # Remove trailing "or "
157- port_checks="${port_checks% or }"
158-
159- PORT_COUNT=$(replicated cluster port ls $CLUSTER_ID --output json | jq -r ".[] | select($port_checks) | .upstream_port" | wc -l | tr -d ' ')
160- [ "$PORT_COUNT" -eq "$expected_count" ]
16188 cmds :
162- - task : utils:port-operations
89+ - task : dev:shell
16390 vars :
164- OPERATION : " expose"
165- deps :
166- - cluster-create
91+ CMD : " task ports-expose"
16792
16893 helm-deploy :
16994 desc : Deploy all charts using helmfile
170- silent : false
17195 cmds :
172- - echo "Installing all charts via helmfile"
173- - |
174- # Get cluster ID
175- CLUSTER_ID=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .id')
176- if [ -z "$CLUSTER_ID" ]; then
177- echo "Error: Could not find cluster with name {{.CLUSTER_NAME}}"
178- exit 1
179- fi
180-
181- # Get exposed URLs
182- ENV_VARS=$(task utils:port-operations OPERATION=getenv CLUSTER_NAME={{.CLUSTER_NAME}})
183-
184- # Deploy with helmfile
185- echo "Using $ENV_VARS"
186- eval "KUBECONFIG={{.KUBECONFIG_FILE}} $ENV_VARS helmfile sync --wait"
187- - echo "All charts deployed!"
188- deps :
189- - setup-kubeconfig
190- - ports-expose
191-
96+ - task : dev:shell
97+ vars :
98+ CMD : " task helm-deploy"
19299
193100 cluster-delete :
194101 desc : Delete all test clusters with matching name and clean up kubeconfig
195- silent : false
196102 cmds :
197- - echo "Deleting clusters named {{.CLUSTER_NAME}}..."
198- - |
199- CLUSTER_IDS=$(replicated cluster ls | grep "{{.CLUSTER_NAME}}" | awk '{print $1}')
200- if [ -z "$CLUSTER_IDS" ]; then
201- echo "No clusters found with name {{.CLUSTER_NAME}}"
202- exit 0
203- fi
204-
205- for id in $CLUSTER_IDS; do
206- echo "Deleting cluster ID: $id"
207- replicated cluster rm "$id"
208- done
209- - |
210- # Clean up kubeconfig file
211- if [ -f "{{.KUBECONFIG_FILE}}" ]; then
212- echo "Removing kubeconfig file {{.KUBECONFIG_FILE}}"
213- rm "{{.KUBECONFIG_FILE}}"
214- fi
215- - echo "All matching clusters deleted and kubeconfig cleaned up!"
103+ - task : dev:shell
104+ vars :
105+ CMD : " task cluster-delete"
216106
217107 release-prepare :
218108 desc : Prepare release files by copying replicated YAML files and packaging Helm charts
219- silent : false
220109 cmds :
221- - echo "Preparing release files..."
222- - rm -rf ./release
223- - mkdir -p ./release
224-
225- # Copy all non-config.yaml files
226- - echo "Copying non-config YAML files to release folder..."
227- - find . -path '*/replicated/*.yaml' -not -name 'config.yaml' -exec cp {} ./release/ \;
228- - find ./replicated -name '*.yaml' -not -name 'config.yaml' -exec cp {} ./release/ \; 2>/dev/null || true
229-
230- # extract namespaces from helmChart files
231- - yq ea '[.spec.namespace] | unique' */replicated/helmChart-*.yaml | yq '.spec.additionalNamespaces *= load("/dev/stdin") | .spec.additionalNamespaces += "*" ' replicated/application.yaml > release/application.yaml.new
232- - mv release/application.yaml.new release/application.yaml
233-
234- # set helmChart versions from associated helm Chart.yaml
235- - echo "Setting helmChart versions..."
236- - |
237- while read directory; do
238-
239- echo $directory
240- parent=$(basename $(dirname $directory))
241-
242- helmChartName="helmChart-$parent.yaml"
243- export version=$(yq -r '.version' $parent/Chart.yaml )
244-
245- yq '.spec.chart.chartVersion = strenv(version) | .spec.chart.chartVersion style="single"' $directory/$helmChartName | tee release/$helmChartName
246-
247- done < <(find . -maxdepth 2 -mindepth 2 -type d -name replicated)
248-
249- # Merge config.yaml files
250- - echo "Merging config.yaml files..."
251- - |
252- # Start with an empty config file
253- echo "{}" > ./release/config.yaml
254-
255- # Merge all app config.yaml files first (excluding root replicated)
256- for config_file in $(find . -path '*/replicated/config.yaml' | grep -v "^./replicated/"); do
257- echo "Merging $config_file..."
258- yq eval-all '. as $item ireduce ({}; . * $item)' ./release/config.yaml "$config_file" > ./release/config.yaml.new
259- mv ./release/config.yaml.new ./release/config.yaml
260- done
261-
262- # Merge root config.yaml last
263- if [ -f "./replicated/config.yaml" ]; then
264- echo "Merging root config.yaml last..."
265- yq eval-all '. as $item ireduce ({}; . * $item)' ./release/config.yaml "./replicated/config.yaml" > ./release/config.yaml.new
266- mv ./release/config.yaml.new ./release/config.yaml
267- fi
268-
269- # Package Helm charts
270- - echo "Packaging Helm charts..."
271- - |
272- # Find top-level directories containing Chart.yaml files
273- for chart_dir in $(find . -maxdepth 2 -name "Chart.yaml" | xargs dirname); do
274- echo "Packaging chart: $chart_dir"
275- # Navigate to chart directory, package it, and move the resulting .tgz to release folder
276- (cd "$chart_dir" && helm package . && mv *.tgz ../release/)
277- done
278-
279- - echo "Release files prepared in ./release/ directory"
280- deps :
281- - update-version
282-
110+ - task : dev:shell
111+ vars :
112+ CMD : " task release-prepare"
283113
284114 release-create :
285115 desc : Create and promote a release using the Replicated CLI
286- silent : false
287- vars :
288- CHANNEL : ' {{.CHANNEL | default "Unstable"}}'
289- RELEASE_NOTES : ' {{.RELEASE_NOTES | default "Release created via task release-create"}}'
290116 cmds :
291- - echo "Creating and promoting release for $APP_NAME to channel $CHANNEL..."
292- - |
293- # Create and promote the release in one step
294- echo "Creating release from files in ./release directory..."
295- replicated release create --app $APP_NAME --yaml-dir ./release --release-notes "$RELEASE_NOTES" --promote $CHANNEL --version $VERSION
296- echo "Release version $VERSION created and promoted to channel $CHANNEL"
297- deps :
298- - release-prepare
117+ - task : dev:shell
118+ vars :
119+ CMD : " task release-create"
299120
300121 gcp-vm-create :
301122 desc : Create a simple GCP VM instance
302- silent : false
303- vars :
304- GCP_MACHINE_TYPE : ' {{.GCP_MACHINE_TYPE | default "e2-standard-2"}}'
305- GCP_DISK_SIZE : ' {{.GCP_DISK_SIZE | default "100"}}'
306- GCP_DISK_TYPE : ' {{.GCP_DISK_TYPE | default "pd-standard"}}'
307- GCP_IMAGE_FAMILY : ' {{.GCP_IMAGE_FAMILY | default "ubuntu-2204-lts"}}'
308- GCP_IMAGE_PROJECT : ' {{.GCP_IMAGE_PROJECT | default "ubuntu-os-cloud"}}'
309- status :
310- - gcloud compute instances describe {{.VM_NAME}} --project={{.GCP_PROJECT}} --zone={{.GCP_ZONE}} &>/dev/null
311123 cmds :
312- - task : utils:gcp-operations
124+ - task : dev:shell
313125 vars :
314- OPERATION : " create"
315- GCP_MACHINE_TYPE : ' {{.GCP_MACHINE_TYPE}}'
316- GCP_DISK_SIZE : ' {{.GCP_DISK_SIZE}}'
317- GCP_DISK_TYPE : ' {{.GCP_DISK_TYPE}}'
318- GCP_IMAGE_FAMILY : ' {{.GCP_IMAGE_FAMILY}}'
319- GCP_IMAGE_PROJECT : ' {{.GCP_IMAGE_PROJECT}}'
126+ CMD : " task gcp-vm-create"
320127
321128 gcp-vm-delete :
322129 desc : Delete the GCP VM instance for K8s and VPN
323- silent : false
324- status :
325- - " ! gcloud compute instances describe {{.VM_NAME}} --project={{.GCP_PROJECT}} --zone={{.GCP_ZONE}} &>/dev/null"
326130 cmds :
327- - task : utils:gcp-operations
131+ - task : dev:shell
328132 vars :
329- OPERATION : " delete"
330- GCP_PROJECT : ' {{.GCP_PROJECT}}'
331- GCP_ZONE : ' {{.GCP_ZONE}}'
332- VM_NAME : ' {{.VM_NAME}}'
133+ CMD : " task gcp-vm-delete"
333134
334135 embedded-cluster-setup :
335136 desc : Setup Replicated embedded cluster on the GCP VM
336- silent : false
337- vars :
338- CHANNEL : ' {{.CHANNEL | default "Unstable"}}'
339- AUTH_TOKEN : ' {{.AUTH_TOKEN | default "2usDXzovcJNcpn54yS5tFQVNvCq"}}'
340- deps :
341- - gcp-vm-create
342- status :
343- - |
344- # Check if the application tarball has already been downloaded and extracted
345- gcloud compute ssh {{.VM_NAME}} --project={{.GCP_PROJECT}} --zone={{.GCP_ZONE}} --command="test -d ./{{.APP_NAME}}" &>/dev/null
346137 cmds :
347- - task : utils:gcp-operations
138+ - task : dev:shell
348139 vars :
349- OPERATION : " setup-embedded"
350- APP_NAME : ' {{.APP_NAME}}'
351- CHANNEL : ' {{.CHANNEL}}'
352- AUTH_TOKEN : ' {{.AUTH_TOKEN}}'
353- GCP_PROJECT : ' {{.GCP_PROJECT}}'
354- GCP_ZONE : ' {{.GCP_ZONE}}'
355- VM_NAME : ' {{.VM_NAME}}'
140+ CMD : " task embedded-cluster-setup"
356141
357142 full-test-cycle :
358143 desc : Create cluster, get kubeconfig, expose ports, update dependencies, deploy charts, test, and delete
359- silent : false
360144 cmds :
361- - task : cluster-create
362- - task : setup-kubeconfig
363- - task : ports-expose
364- - task : dependencies-update
365- - task : helm-deploy
366- - task : test
367- - task : cluster-delete
145+ - task : dev:shell
146+ vars :
147+ CMD : " task full-test-cycle"
0 commit comments