Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/on-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
{ "example": "examples/gitopsstacks/minimal.yaml" },
{ "example": "examples/gitopsstacks/standard.yaml" },
{ "example": "examples/gitopsstacks/webhook.yaml" },
{ "example": "examples/gitopsstacks/private-ui.yaml" },
{ "example": "examples/gitopsstacks/webhook-only.yaml" },
{ "example": "examples/gitopsstacks/nodepool.yaml" },
{ "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/1/" },
{ "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/2/" },
{ "example": "examples/gitopsstacks/eso.yaml" },
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/on-push-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
{ "example": "examples/gitopsstacks/minimal.yaml" },
{ "example": "examples/gitopsstacks/standard.yaml" },
{ "example": "examples/gitopsstacks/webhook.yaml" },
{ "example": "examples/gitopsstacks/private-ui.yaml" },
{ "example": "examples/gitopsstacks/webhook-only.yaml" },
{ "example": "examples/gitopsstacks/nodepool.yaml" },
{ "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/1/" },
{ "example": "examples/gitopsstacks/standard.yaml", "observed_resources": "examples/test/mocks/observed-resources/standard/steps/2/" },
{ "example": "examples/gitopsstacks/eso.yaml" },
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ EXAMPLES := \
examples/gitopsstacks/standard.yaml:: \
examples/gitopsstacks/nodepool.yaml:: \
examples/gitopsstacks/webhook.yaml:: \
examples/gitopsstacks/private-ui.yaml:: \
examples/gitopsstacks/webhook-only.yaml:: \
examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/1/ \
examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/2/ \
examples/gitopsstacks/eso.yaml:: \
Expand All @@ -46,6 +48,7 @@ render\:all:
observed=$${entry#*::}; \
outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \
( \
set -euo pipefail; \
if [ -n "$$observed" ]; then \
echo "=== Rendering $$example with observed-resources $$observed ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example --observed-resources=$$observed; \
Expand Down Expand Up @@ -76,6 +79,7 @@ validate\:all: generate-configuration
observed=$${entry#*::}; \
outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \
( \
set -euo pipefail; \
if [ -n "$$observed" ]; then \
echo "=== Validating $$example with observed-resources $$observed ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
Expand Down
70 changes: 68 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,73 @@ This creates a GitHub `push` webhook for
`https://argocd.example.com/api/webhook`. The generated secret uses
`updatePolicy: IfNotExists` and is retained when the stack is deleted, making
AWS Secrets Manager the durable source of truth. SecretStack, a path under its
`push/*` write boundary, and a public ArgoCD Gateway route are required. Set
`push/*` write boundary, and a publicly reachable webhook endpoint are required. Set
`generate: false` to read a pre-existing secret from another path instead.


#### Private UI with a separate public webhook

Set `repository.webhook.url` to a public HTTPS endpoint when the UI hostname
resolves to a private Gateway. The URL must end in `/api/webhook` and cannot
contain credentials, a query string or a fragment. An explicit port must be
between 1 and 65535. Without this override the
existing `https://<exposure.hostname>/api/webhook` behavior is unchanged.

```yaml
spec:
exposure:
enabled: true
hostname: argocd.example.com
gatewayRef:
name: private
namespace: ingress
sectionName: https-argocd
routeAnnotations:
external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
repository:
org: hops-ops
webhook:
enabled: true
url: https://argocd-webhook.example.com/api/webhook
secretPath: push/example-cluster/argo/github-webhook
```

The webhook override updates the URL exported in the shared Kubernetes Secret;
GitopsEnvironment consumers of that Secret follow it on reconciliation. It does
not rotate the HMAC secret, change the UI URL, alter native OIDC callbacks or
create a public route. Provision a separate public HTTPRoute before changing
webhook URLs. Restrict that route to `POST` and the exact `/api/webhook` path,
backed by `argocd-server:80` in the Argo namespace; keep all UI/API paths private.
Require `X-GitHub-Event` to be `push` or `ping`, and remove competing provider
headers (`X-Vss-Activityid`, `X-Gogs-Event`, `X-Gitlab-Event`, `X-Hook-UUID`,
`X-Event-Key`) before forwarding. Argo shares this endpoint across providers;
these restrictions ensure requests use the GitHub handler and its existing
shared HMAC verification. Verify new GitHub deliveries
before moving the UI's DNS and Gateway parent. A webhook may also use an explicit
URL with `exposure.enabled: false` if routing is managed separately. In that
case the XR does not select backend TLS for the externally managed route. For
TLS termination at the Gateway with an HTTP `argocd-server:80` backend, set:

```yaml
spec:
argocd:
values:
configs:
params:
server.insecure: "true"
```

Alternatively, keep Argo's server TLS enabled and configure the externally
managed Gateway's backend TLS appropriately. Match the backend scheme to this
setting: GitHub webhook POSTs must reach the handler without an HTTP-to-HTTPS
redirect. The public webhook URL itself remains HTTPS in either case.

`exposure.routeAnnotations` applies only to the UI HTTPRoute. Typed annotation
keys take precedence over matching `argocd.values.server.httproute.annotations`
keys while retaining unrelated raw annotations. Other Helm values and resources
are unaffected. The public/private network boundary belongs to the chosen
Gateway and DNS target; annotations alone do not make an endpoint private.

### Stage 3: Crossplane Integration

Enable ArgoCD-managed Crossplane resources for full platform automation.
Expand Down Expand Up @@ -308,7 +372,8 @@ The Usage ensures ArgoCD CRDs stay alive until all ArgoCD Application CRs are cl
| `argocd.values` | object | no | `{}` | Helm values merged with defaults |
| `argocd.overrideAllValues` | object | no | — | Helm values replacing all defaults |
| `exposure.enabled` | boolean | no | `false` | Create an ArgoCD HTTPRoute |
| `exposure.hostname` | string | with exposure | — | Public ArgoCD hostname |
| `exposure.hostname` | string | with exposure | — | ArgoCD UI hostname |
| `exposure.routeAnnotations` | map of strings | no | `{}` | Annotations on only the ArgoCD HTTPRoute |
| `exposure.gatewayRef.*` | object | no | `platform` / `istio-ingress` / `https` | Existing Gateway listener |
| `auth.oidc.enabled` | boolean | no | `false` | Enable native ArgoCD OIDC with Zitadel |
| `auth.oidc.issuerURL` | string | with OIDC | — | Zitadel issuer URL |
Expand All @@ -325,6 +390,7 @@ The Usage ensures ArgoCD CRDs stay alive until all ArgoCD Application CRs are cl
| `repository.topics` | []string | no | `[]` | Repository topics |
| `repository.deleteBranchOnMerge` | boolean | no | `true` | Auto-delete head branches on merge |
| `repository.webhook.enabled` | boolean | no | `false` | Create a signed GitHub push webhook for immediate ArgoCD refreshes |
| `repository.webhook.url` | string | no | `https://<exposure.hostname>/api/webhook` | Independent public HTTPS webhook endpoint |
| `repository.webhook.generate` | boolean | no | `true` | Generate the shared secret once and push it to AWS Secrets Manager |
| `repository.webhook.secretStoreName` | string | no | `externalSecrets.secretStoreName` or `default` | ClusterSecretStore used to push and read the shared secret |
| `repository.webhook.secretPath` | string | when enabled | — | AWS Secrets Manager path containing the shared secret |
Expand Down
21 changes: 15 additions & 6 deletions apis/gitopsstacks/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,22 @@ spec:
type: object
x-kubernetes-preserve-unknown-fields: true
exposure:
description: Optional public exposure of the ArgoCD server through an existing Gateway API Gateway.
description: Optional exposure of the ArgoCD server through an existing public or private Gateway API Gateway.
type: object
properties:
enabled:
description: Enable an HTTPRoute for the ArgoCD server. Defaults to false.
type: boolean
default: false
hostname:
description: Public DNS hostname for ArgoCD.
description: DNS hostname for ArgoCD.
type: string
minLength: 1
routeAnnotations:
description: Annotations applied to the ArgoCD HTTPRoute, including per-route DNS provider settings.
type: object
additionalProperties:
type: string
gatewayRef:
description: Existing Gateway listener that accepts the ArgoCD HTTPRoute.
type: object
Expand Down Expand Up @@ -262,13 +267,17 @@ spec:
type: boolean
default: false
webhook:
description: GitHub webhook that immediately refreshes ArgoCD Applications when the repository changes. Requires SecretStack and public ArgoCD exposure.
description: GitHub webhook that immediately refreshes ArgoCD Applications when the repository changes. Requires SecretStack and a publicly reachable webhook endpoint.
type: object
properties:
enabled:
description: Create a push webhook targeting the exposed ArgoCD server. Defaults to false.
description: Create a push webhook targeting ArgoCD. Defaults to false.
type: boolean
default: false
url:
description: Public HTTPS ArgoCD webhook URL ending in /api/webhook. Defaults to https://<exposure.hostname>/api/webhook. Set this independently when the UI uses private exposure.
type: string
pattern: '^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}))?/api/webhook$'
generate:
description: Generate the shared secret and push it to AWS Secrets Manager. Defaults to true. Set false to use a pre-existing secret.
type: boolean
Expand Down Expand Up @@ -366,8 +375,8 @@ spec:
x-kubernetes-validations:
- rule: "!has(self.auth) || !has(self.auth.oidc) || !self.auth.oidc.enabled || (has(self.exposure) && self.exposure.enabled)"
message: spec.exposure.enabled must be true when native OIDC is enabled
- rule: "!has(self.repository) || !has(self.repository.webhook) || !self.repository.webhook.enabled || (has(self.exposure) && self.exposure.enabled)"
message: spec.exposure.enabled must be true when the GitHub webhook is enabled
- rule: "!has(self.repository) || !has(self.repository.webhook) || !self.repository.webhook.enabled || has(self.repository.webhook.url) || (has(self.exposure) && self.exposure.enabled)"
message: spec.exposure.enabled must be true when the GitHub webhook is enabled unless spec.repository.webhook.url is provided
status:
description: GitopsStackStatus defines the observed state.
type: object
Expand Down
24 changes: 24 additions & 0 deletions examples/gitopsstacks/private-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: hops.ops.com.ai/v1alpha1
kind: GitopsStack
metadata:
name: gitops
namespace: example-env
spec:
clusterName: example-cluster
exposure:
enabled: true
hostname: argocd.example.com
gatewayRef:
name: private
namespace: ingress
sectionName: https-argocd
routeAnnotations:
external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
repository:
org: hops-ops
name: example-cluster-gitops
webhook:
enabled: true
url: https://argocd-webhook.example.com/api/webhook
secretStoreName: default
secretPath: push/example-cluster/argo/github-webhook
22 changes: 22 additions & 0 deletions examples/gitopsstacks/webhook-only.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: hops.ops.com.ai/v1alpha1
kind: GitopsStack
metadata:
name: gitops
namespace: example-env
spec:
clusterName: example-cluster
argocd:
values:
configs:
params:
server.insecure: "true"
exposure:
enabled: false
repository:
org: hops-ops
name: example-cluster-gitops
webhook:
enabled: true
url: https://argocd-webhook.example.com/api/webhook
secretStoreName: default
secretPath: push/example-cluster/argo/github-webhook
13 changes: 9 additions & 4 deletions functions/render/000-state-init.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
{{- $argocdSpec := $spec.argocd | default dict }}

# ==============================================================================
# Public exposure
# Gateway exposure
# ==============================================================================
{{- $exposureSpec := $spec.exposure | default dict }}
{{- $exposureEnabled := false }}
Expand Down Expand Up @@ -168,8 +168,12 @@
{{- if and $webhookEnabled $webhookGenerate (not (hasPrefix "push/" ($webhookSpec.secretPath | default ""))) }}
{{- fail "spec.repository.webhook.secretPath must start with push/ when secret generation is enabled" }}
{{- end }}
{{- if and $webhookEnabled (not $exposureEnabled) }}
{{- fail "spec.exposure.enabled must be true when the GitHub webhook is enabled" }}
{{- $webhookURLOverride := $webhookSpec.url | default "" }}
{{- if and (hasKey $webhookSpec "url") (not (regexMatch `^https://[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?(:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}))?/api/webhook$` $webhookURLOverride)) }}
{{- fail "spec.repository.webhook.url must be an HTTPS endpoint ending in /api/webhook without credentials, query or fragment" }}
{{- end }}
{{- if and $webhookEnabled (not $exposureEnabled) (eq $webhookURLOverride "") }}
{{- fail "spec.exposure.enabled must be true when the GitHub webhook is enabled unless spec.repository.webhook.url is provided" }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
{{- end }}

# Template config (optional)
Expand Down Expand Up @@ -229,6 +233,7 @@
"exposure" (dict
"enabled" $exposureEnabled
"hostname" $exposureHostname
"routeAnnotations" ($exposureSpec.routeAnnotations | default dict)
"gatewayRef" (dict
"name" ($gatewayRefSpec.name | default "platform")
"namespace" ($gatewayRefSpec.namespace | default "istio-ingress")
Expand Down Expand Up @@ -280,7 +285,7 @@
"generatorName" (printf "%s-github-webhook" $name)
"providerSecretName" (printf "%s-github-webhook" $name)
"argocdSecretName" (printf "%s-argocd-github-webhook" $name)
"url" (printf "https://%s/api/webhook" $exposureHostname)
"url" ($webhookURLOverride | default (printf "https://%s/api/webhook" $exposureHostname))
"maxPayloadSizeMB" ($webhookSpec.maxPayloadSizeMB | default 10)
)
)
Expand Down
3 changes: 3 additions & 0 deletions functions/render/200-helm-release-argocd.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ spec:
)
)
}}
{{- with $state.exposure.routeAnnotations }}
{{- $_ := set $exposureValues.server.httproute "annotations" . }}
{{- end }}
{{- $effectiveValues = mergeOverwrite $effectiveValues $exposureValues }}
{{- end }}

Expand Down
Loading
Loading