Skip to content

Commit 8729219

Browse files
authored
Merge branch 'main' into feat-notes
Signed-off-by: Alan Clucas <[email protected]>
2 parents b585dfd + cb39b3e commit 8729219

File tree

14 files changed

+242
-102
lines changed

14 files changed

+242
-102
lines changed

.devcontainer/builder/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# TODO: Upgrade to Ubuntu 24.04 when https://bugs.launchpad.net/ubuntu/+source/curl/+bug/2073448 is addressed
2+
FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu-22.04
3+
4+
# k3d version: https://github.com/k3d-io/k3d/releases
5+
ARG K3D_VERSION=v5.8.3
6+
7+
# TARGETARCH is automatically set by BuildKit to the architecture (e.g. "amd64" or "arm64")
8+
# Docs: https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
9+
ARG TARGETARCH
10+
11+
# Use bash to allow us to source hack/k8s-versions.sh
12+
SHELL ["/bin/bash", "-c"]
13+
14+
# install protocol buffer tools
15+
RUN apt-get update && apt-get install -y protobuf-compiler clang-format
16+
17+
# install k3d
18+
RUN wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${K3D_VERSION} bash
19+
20+
# install kubectl
21+
COPY hack/k8s-versions.sh /tmp/
22+
RUN . /tmp/k8s-versions.sh && \
23+
wget -O /usr/local/bin/kubectl "https://dl.k8s.io/release/${K8S_VERSIONS[min]}/bin/linux/${TARGETARCH}/kubectl" && \
24+
chmod +x /usr/local/bin/kubectl
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Dev container definition for building the image used by .devcontainer/devcontainer.json.
3+
// Docs: https://containers.dev/guide/prebuild#how-to
4+
"name": "Argo Workflows (builder)",
5+
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
"context": "../..",
9+
// Override this hardcoded param from the devcontainer CLI because it bloats
10+
// the image and we export the cache to a separate image:
11+
// https://github.com/devcontainers/cli/blob/2fafdcc8a8dee5a922616325f3726043f1ea92c3/src/spec-node/singleContainer.ts#L208
12+
"args": { "BUILDKIT_INLINE_CACHE": "0" }
13+
},
14+
15+
"features": {
16+
"ghcr.io/devcontainers/features/go:1": {
17+
"version": "1.24"
18+
},
19+
"ghcr.io/devcontainers/features/node:1": {
20+
"version": "20"
21+
},
22+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
23+
"ghcr.io/devcontainers/features/python:1": {}
24+
}
25+
}

.devcontainer/devcontainer.json

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
{
2-
// TODO: Bump to ubuntu-24.04 once Python issues are fixed: https://github.com/argoproj/argo-workflows/pull/14302#issuecomment-2742883052
3-
"image": "mcr.microsoft.com/vscode/devcontainers/base:ubuntu-22.04",
4-
"appPort": 8080,
5-
"features": {
6-
"ghcr.io/devcontainers/features/go:1": {
7-
"version": "1.24"
8-
},
9-
"ghcr.io/devcontainers/features/node:1": {
10-
"version": "20"
11-
},
12-
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
13-
"ghcr.io/devcontainers/features/python:1": {}
14-
},
2+
// Dev container definition. Reference: https://containers.dev/implementors/json_reference/
3+
"name": "Argo Workflows (pre-built)",
4+
5+
// This image is built and pushed by .github/workflows/devcontainer.yaml using .devcontainer/builder/devcontainer.json
6+
"image": "quay.io/argoproj/argo-workflows-devcontainer",
7+
158
"forwardPorts": [9000, 9001, 9090, 2746, 8080, 5556, 6060, 9091, 3306, 5432, 10000, 8000],
169
"hostRequirements": {
1710
"cpus": 4
@@ -32,24 +25,29 @@
3225
"GOPATH": "/home/vscode/go"
3326
},
3427
"customizations": {
28+
"codespaces": {
29+
"openFiles": [
30+
"docs/running-locally.md"
31+
]
32+
},
3533
"vscode": {
3634
"settings": {
3735
"launch": {
3836
"configurations": [
39-
{
40-
"name": "Attach to argo server",
41-
"type": "go",
42-
"request": "attach",
43-
"mode": "local",
44-
"processId": "argo"
45-
},
46-
{
47-
"name": "Attach to workflow controller",
48-
"type": "go",
49-
"request": "attach",
50-
"mode": "local",
51-
"processId": "workflow-controller"
52-
}
37+
{
38+
"name": "Attach to argo server",
39+
"type": "go",
40+
"request": "attach",
41+
"mode": "local",
42+
"processId": "argo"
43+
},
44+
{
45+
"name": "Attach to workflow controller",
46+
"type": "go",
47+
"request": "attach",
48+
"mode": "local",
49+
"processId": "workflow-controller"
50+
}
5351
]
5452
}
5553
}

.devcontainer/pre-build.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
#!/usr/bin/env bash
22
set -eux
33

4-
# install kubernetes using the minimum tested version
4+
# create cluster using the minimum tested Kubernetes version
55
. hack/k8s-versions.sh
6-
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
76
k3d cluster get k3s-default || k3d cluster create --image "rancher/k3s:${K8S_VERSIONS[min]}-k3s1" --wait
87
k3d kubeconfig merge --kubeconfig-merge-default
9-
10-
# install kubectl
11-
curl -LO "https://dl.k8s.io/release/${K8S_VERSIONS[min]}/bin/linux/$(go env GOARCH)/kubectl"
12-
chmod +x ./kubectl
13-
sudo mv ./kubectl /usr/local/bin/kubectl
148
kubectl cluster-info
159

16-
# install protocol buffer compiler (protoc)
17-
sudo apt update
18-
sudo apt install -y protobuf-compiler
19-
2010
# Make sure go path is owned by vscode
2111
sudo chown vscode:vscode /home/vscode/go || true
2212
sudo chown vscode:vscode /home/vscode/go/src || true
2313
sudo chown vscode:vscode /home/vscode/go/src/github.com || true
2414

25-
# install kit
26-
make kit
27-
28-
# download dependencies and do first-pass compile
29-
kit build
30-
3115
# Patch CoreDNS to have host.docker.internal inside the cluster available
3216
kubectl get cm coredns -n kube-system -o yaml | sed "s/ NodeHosts: |/ NodeHosts: |\n `grep host.docker.internal /etc/hosts`/" | kubectl apply -f -

.github/workflows/devcontainer.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Dev Container
2+
3+
on:
4+
push:
5+
paths:
6+
- ".devcontainer/**"
7+
- "hack/k8s-versions.sh"
8+
- ".github/workflows/devcontainer.yaml"
9+
branches:
10+
- main
11+
pull_request:
12+
paths:
13+
- ".devcontainer/**"
14+
- "hack/k8s-versions.sh"
15+
- ".github/workflows/devcontainer.yaml"
16+
branches:
17+
- main
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
jobs:
28+
build:
29+
runs-on: ubuntu-24.04
30+
if: github.repository == 'argoproj/argo-workflows'
31+
steps:
32+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
33+
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
34+
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
35+
- name: Login to registry
36+
if: ${{ github.event_name == 'push' }}
37+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
38+
with:
39+
registry: quay.io
40+
username: ${{ secrets.QUAYIO_USERNAME }}
41+
password: ${{ secrets.QUAYIO_PASSWORD }}
42+
- name: Build dev container image
43+
run: make devcontainer-build
44+
env:
45+
TARGET_PLATFORM: linux/amd64,linux/arm64
46+
DEVCONTAINER_PUSH: ${{ github.event_name == 'push' && 'true' || 'false' }}

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ DOCKER_PUSH ?= false
3333
TARGET_PLATFORM ?= linux/$(shell go env GOARCH)
3434
K3D_CLUSTER_NAME ?= k3s-default # declares which cluster to import to in case it's not the default name
3535

36+
# -- dev container options
37+
DEVCONTAINER_PUSH ?= false
38+
# Extract image name from devcontainer.json
39+
DEVCONTAINER_IMAGE ?= $(shell sed --quiet 's/^ *"image": "\([^"]*\)",/\1/p' .devcontainer/devcontainer.json)
40+
ifeq ($(DEVCONTAINER_PUSH),true)
41+
# Export both image and cache to the registry using zstd, since that produces much smaller images than gzip.
42+
# Docs: https://docs.docker.com/build/exporters/image-registry/ and https://docs.docker.com/build/cache/backends/registry/
43+
DEVCONTAINER_EXPORTER_COMMON_FLAGS ?= type=registry,compression=zstd,force-compression=true,oci-mediatypes=true
44+
DEVCONTAINER_FLAGS ?= --output $(DEVCONTAINER_EXPORTER_COMMON_FLAGS) \
45+
--cache-to $(DEVCONTAINER_EXPORTER_COMMON_FLAGS),ref=$(DEVCONTAINER_IMAGE):cache,mode=max
46+
else
47+
DEVCONTAINER_FLAGS ?= --output type=cacheonly
48+
endif
49+
3650
# -- test options
3751
E2E_WAIT_TIMEOUT ?= 90s # timeout for wait conditions
3852
E2E_PARALLEL ?= 20
@@ -116,6 +130,7 @@ TOOL_CLANG_FORMAT := /usr/local/bin/clang-format
116130
TOOL_MDSPELL := $(NVM_BIN)/mdspell
117131
TOOL_MARKDOWN_LINK_CHECK := $(NVM_BIN)/markdown-link-check
118132
TOOL_MARKDOWNLINT := $(NVM_BIN)/markdownlint
133+
TOOL_DEVCONTAINER := $(NVM_BIN)/devcontainer
119134
TOOL_MKDOCS_DIR := $(HOME)/.venv/mkdocs
120135
TOOL_MKDOCS := $(TOOL_MKDOCS_DIR)/bin/mkdocs
121136

@@ -823,6 +838,7 @@ release-notes: /dev/null
823838
checksums:
824839
sha256sum ./dist/argo-*.gz | awk -F './dist/' '{print $$1 $$2}' > ./dist/argo-workflows-cli-checksums.txt
825840

841+
# feature notes
826842
FEATURE_FILENAME?=$(shell git branch --show-current)
827843
.PHONY: feature-new
828844
feature-new: hack/featuregen/featuregen
@@ -856,3 +872,22 @@ features-release: hack/featuregen/featuregen
856872
hack/featuregen/featuregen: hack/featuregen/main.go hack/featuregen/contents.go hack/featuregen/contents_test.go hack/featuregen/main_test.go
857873
go test ./hack/featuregen
858874
go build -o $@ ./hack/featuregen
875+
876+
# dev container
877+
878+
$(TOOL_DEVCONTAINER): Makefile
879+
npm list -g @devcontainers/[email protected] > /dev/null || npm i -g @devcontainers/[email protected]
880+
881+
.PHONY: devcontainer-build
882+
devcontainer-build: $(TOOL_DEVCONTAINER)
883+
devcontainer build \
884+
--workspace-folder . \
885+
--config .devcontainer/builder/devcontainer.json \
886+
--platform $(TARGET_PLATFORM) \
887+
--image-name $(DEVCONTAINER_IMAGE) \
888+
--cache-from $(DEVCONTAINER_IMAGE):cache \
889+
$(DEVCONTAINER_FLAGS)
890+
891+
.PHONY: devcontainer-up
892+
devcontainer-up: $(TOOL_DEVCONTAINER)
893+
devcontainer up --workspace-folder .

docs/running-locally.md

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,33 @@
11
# Running Locally
22

3-
You have two options:
3+
## Development Environment Setup
44

5-
1. Use the [Dev Container](#development-container). This takes about 7 minutes. This can be used with VSCode, the `devcontainer` CLI, or GitHub Codespaces.
6-
1. Install the [requirements](#requirements) on your computer manually. This takes about 1 hour.
5+
You have two options for setting up your development environment:
76

8-
## Development Container
7+
1. Use the [Dev Container](#development-container), either locally or via [GitHub Codespaces](https://github.com/codespaces). This is usually the fastest and easiest way to get started.
8+
1. [Manual installation](#manual-installation) of the necessary tooling. This requires a basic understanding of administering Kubernetes and package management for your OS.
99

10-
The development container should be able to do everything you need to do to develop Argo Workflows without installing tools on your local machine. It takes quite a long time to build the container. It runs `k3d` inside the container so you have a cluster to test against. To communicate with services running either in other development containers or directly on the local machine (e.g. a database), the following URL can be used in the workflow spec: `host.docker.internal:<PORT>`. This facilitates the implementation of workflows which need to connect to a database or an API server.
10+
### Initial Local Setup
11+
12+
Unless you're using GitHub Codespaces, the first step is cloning the Git repo into `$GOPATH/src/github.com/argoproj/argo-workflows`. Any other path will break the code generation.
13+
14+
### Development Container
15+
16+
Prebuilt [development container](https://containers.dev/) images are provided for both `amd64` and `arm64` containing all you need to develop Argo Workflows, without installing tools on your local machine. Provisioning a dev container is fully automated and typically takes ~1 minute.
1117

1218
You can use the development container in a few different ways:
1319

1420
1. [Visual Studio Code](https://code.visualstudio.com/) with [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). Open your `argo-workflows` folder in VSCode and it should offer to use the development container automatically. VSCode will allow you to forward ports to allow your external browser to access the running components.
15-
1. [`devcontainer` CLI](https://github.com/devcontainers/cli). Once installed, go to your `argo-workflows` folder and run `devcontainer up --workspace-folder .` followed by `devcontainer exec --workspace-folder . /bin/bash` to get a shell where you can build the code. You can use any editor outside the container to edit code; any changes will be mirrored inside the container. Due to a limitation of the CLI, only port 8080 (the Web UI) will be exposed for you to access if you run this way. Other services are usable from the shell inside.
21+
1. [`devcontainer` CLI](https://github.com/devcontainers/cli). In your `argo-workflows` folder, run `make devcontainer-up`, which will automatically install the CLI and start the container. Then, use `devcontainer exec --workspace-folder . /bin/bash` to get a shell where you can build the code. You can use any editor outside the container to edit code; any changes will be mirrored inside the container. Due to a limitation of the CLI, only port 8080 (the Web UI) will be exposed for you to access if you run this way. Other services are usable from the shell inside.
1622
1. [GitHub Codespaces](https://github.com/codespaces). You can start editing as soon as VSCode is open, though you may want to wait for `pre-build.sh` to finish installing dependencies, building binaries, and setting up the cluster before running any commands in the terminal. Once you start running services (see next steps below), you can click on the "PORTS" tab in the VSCode terminal to see all forwarded ports. You can open the Web UI in a new tab from there.
1723

1824
Once you have entered the container, continue to [Developing Locally](#developing-locally).
1925

20-
Note:
21-
22-
* for **Apple Silicon**
23-
* This platform can spend 3 times the indicated time
24-
* Configure Docker Desktop to use BuildKit:
25-
26-
```json
27-
"features": {
28-
"buildkit": true
29-
},
30-
```
31-
32-
* For **Windows WSL2**
33-
* Configure [`.wslconfig`](https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configuration-setting-for-wslconfig) to limit memory usage by the WSL2 to prevent VSCode OOM.
34-
35-
* For **Linux**
36-
* Use [Docker Desktop](https://docs.docker.com/desktop/linux/install/) instead of [Docker Engine](https://docs.docker.com/engine/install/) to prevent incorrect network configuration by k3d.
37-
38-
## Requirements
26+
The container runs [k3d](https://k3d.io/) via [docker-in-docker](https://github.com/devcontainers/features/tree/main/src/docker-in-docker) so you have a cluster to test against. To communicate with services running either in other development containers or directly on the local machine (e.g. a database), the following URL can be used in the workflow spec: `host.docker.internal:<PORT>`. This facilitates the implementation of workflows which need to connect to a database or an API server.
3927

40-
Clone the Git repo into: `$GOPATH/src/github.com/argoproj/argo-workflows`. Any other path will break the code generation.
28+
Note for Windows: configure [`.wslconfig`](https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configuration-setting-for-wslconfig) to limit memory usage by the WSL2 to prevent VSCode OOM.
4129

42-
Add the following to your `/etc/hosts`:
43-
44-
```text
45-
127.0.0.1 dex
46-
127.0.0.1 minio
47-
127.0.0.1 postgres
48-
127.0.0.1 mysql
49-
127.0.0.1 azurite
50-
```
30+
### Manual Installation
5131

5232
To build on your own machine without using the Dev Container you will need:
5333

@@ -57,6 +37,15 @@ To build on your own machine without using the Dev Container you will need:
5737
* [`protoc`](http://google.github.io/proto-lens/installing-protoc.html)
5838
* [`node`](https://nodejs.org/download/release/latest-v16.x/) for running the UI
5939
* A local Kubernetes cluster ([`k3d`](https://k3d.io/), [`kind`](https://kind.sigs.k8s.io/docs/user/quick-start/#installation), or [`minikube`](https://minikube.sigs.k8s.io/docs/start/))
40+
* The following entries in your `/etc/hosts` file:
41+
42+
```text
43+
127.0.0.1 dex
44+
127.0.0.1 minio
45+
127.0.0.1 postgres
46+
127.0.0.1 mysql
47+
127.0.0.1 azurite
48+
```
6049
6150
We recommend using [K3D](https://k3d.io/) to set up the local Kubernetes cluster since this will allow you to test RBAC
6251
set-up and is fast. You can set-up K3D to be part of your default kube config as follows:

0 commit comments

Comments
 (0)