diff --git a/README.md b/README.md index bbb4f91..a6b52d1 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,18 @@ helm install celld celld/celld \ Azurite is a development store. celld's emulator client always uses `127.0.0.1:10000`; the chart runs a socat sidecar that forwards that port to the Azurite Service. +`celld dev` (local object store, one Wrangler project, no fleet bucket): + +```bash +helm install celld celld/celld \ + --namespace celld \ + --create-namespace \ + --set dev.enabled=true \ + --set dev.hostPath=/path/visible/on/the/node/to/wrangler-project +``` + +`dev.hostPath` empty uses the chart's placeholder worker and `--no-watch`. The node path must be visible inside the cluster (kind extraMounts / hostPath). Dev mode forces one replica and ignores `azurite` and `celld.bucket`. Health is `GET /.well-known/celld/health`. + `credentials.existingSecret` should contain `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` (plus `AWS_SESSION_TOKEN` when using temporary credentials). For hops `local aws` (INI file under Secret key `credentials`): @@ -62,7 +74,7 @@ helm install celld celld/celld \ | 8080 | Public Worker / Durable Object HTTP | | 8081 | Internal peer + operator API — keep off the public internet | -Health: `GET /__celld/health`. +Health: `GET /__celld/health` (fleet). Dev mode uses `GET /.well-known/celld/health`. ## Values diff --git a/templates/azurite.yaml b/templates/azurite.yaml index 196b7a7..8c51a13 100644 --- a/templates/azurite.yaml +++ b/templates/azurite.yaml @@ -1,4 +1,4 @@ -{{- if .Values.azurite.enabled }} +{{- if and .Values.azurite.enabled (not .Values.dev.enabled) }} apiVersion: v1 kind: Secret metadata: diff --git a/templates/placeholder-worker.yaml b/templates/placeholder-worker.yaml index 7f271ae..eeb08c8 100644 --- a/templates/placeholder-worker.yaml +++ b/templates/placeholder-worker.yaml @@ -1,4 +1,5 @@ -{{- if or .Values.bootstrapPlaceholder (and .Values.azurite.enabled .Values.azurite.bootstrapPlaceholder) }} +{{- $devPlaceholder := and .Values.dev.enabled (not .Values.dev.hostPath) -}} +{{- if or $devPlaceholder .Values.bootstrapPlaceholder (and (not .Values.dev.enabled) .Values.azurite.enabled .Values.azurite.bootstrapPlaceholder) }} apiVersion: v1 kind: ConfigMap metadata: diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml index 09f0a4f..bafdc74 100644 --- a/templates/statefulset.yaml +++ b/templates/statefulset.yaml @@ -3,6 +3,14 @@ {{- $bucket = printf "az://%s" .Values.azurite.container -}} {{- end -}} {{- $placeholder := or .Values.bootstrapPlaceholder (and .Values.azurite.enabled .Values.azurite.bootstrapPlaceholder) -}} +{{- $dev := .Values.dev.enabled -}} +{{- $devHost := .Values.dev.hostPath | default "" -}} +{{- $devMount := .Values.dev.mountPath | default "/workspace" -}} +{{- $devProject := "/var/lib/celld/project" -}} +{{- if $devHost }}{{- $devProject = $devMount }}{{- end -}} +{{- $healthPath := "/__celld/health" -}} +{{- if $dev }}{{- $healthPath = "/.well-known/celld/health" }}{{- end -}} +{{- if $dev }}{{- $placeholder = false }}{{- $bucket = "" }}{{- end -}} {{- $volumeClaimTemplateLabels := dict -}} {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} {{- $existingStatefulSet := lookup "apps/v1" "StatefulSet" .Release.Namespace (include "celld.fullname" .) -}} @@ -20,7 +28,7 @@ metadata: labels: {{- include "celld.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount }} + replicas: {{ if $dev }}1{{ else }}{{ .Values.replicaCount }}{{ end }} serviceName: {{ include "celld.fullname" . }}-internal selector: matchLabels: @@ -43,9 +51,38 @@ spec: securityContext: {{- toYaml . | nindent 8 }} {{- end }} - {{- if or .Values.azurite.enabled $placeholder }} + {{- if or $dev (and (not $dev) (or .Values.azurite.enabled $placeholder)) }} initContainers: - {{- if .Values.azurite.enabled }} + {{- if $dev }} + - name: esbuild + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - /bin/sh + - -c + - | + set -eu + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends curl ca-certificates + mkdir -p /opt/esbuild + cd /opt/esbuild + curl -fsSL https://esbuild.github.io/dl/v0.25.5 | sh + test -x /opt/esbuild/esbuild + {{- if not $devHost }} + mkdir -p /var/lib/celld/project + cp -L /placeholder/index.js /placeholder/wrangler.jsonc /var/lib/celld/project/ + {{- end }} + volumeMounts: + - name: esbuild + mountPath: /opt/esbuild + {{- if not $devHost }} + - name: data + mountPath: /var/lib/celld + - name: placeholder + mountPath: /placeholder + {{- end }} + {{- end }} + {{- if and .Values.azurite.enabled (not $dev) }} - name: azurite-init image: "{{ .Values.azurite.initImage.repository }}:{{ .Values.azurite.initImage.tag }}" imagePullPolicy: {{ .Values.azurite.initImage.pullPolicy }} @@ -128,7 +165,7 @@ spec: {{- end }} {{- end }} containers: - {{- if .Values.azurite.enabled }} + {{- if and .Values.azurite.enabled (not $dev) }} - name: azurite-forward image: "{{ .Values.azurite.socatImage.repository }}:{{ .Values.azurite.socatImage.tag }}" imagePullPolicy: {{ .Values.azurite.socatImage.pullPolicy }} @@ -157,6 +194,22 @@ spec: {{- if include "celld.sharedCredentials.enabled" . }} {{ include "celld.exportSharedCredentials.sh" . | nindent 14 }} {{- end }} + {{- if $dev }} + export PATH="/opt/esbuild:$PATH" + export CELLD_ESBUILD=/opt/esbuild/esbuild + exec /usr/local/bin/celld dev {{ $devProject | quote }} \ + --host 0.0.0.0 \ + --port {{ .Values.dev.port }} \ + {{- if .Values.dev.logs }} + --logs \ + {{- end }} + {{- if .Values.dev.clean }} + --clean \ + {{- end }} + {{- if or (not $devHost) (not .Values.dev.watch) }} + --no-watch + {{- end }} + {{- else }} exec /usr/local/bin/celld \ {{- if $bucket }} --bucket {{ $bucket | quote }} \ @@ -164,9 +217,10 @@ spec: --listen 0.0.0.0:{{ .Values.server.httpPort }} \ --internal-listen 0.0.0.0:{{ .Values.server.internalPort }} \ --advertise "${POD_IP}:{{ .Values.server.internalPort }}" + {{- end }} ports: - name: http - containerPort: {{ .Values.server.httpPort }} + containerPort: {{ if $dev }}{{ .Values.dev.port }}{{ else }}{{ .Values.server.httpPort }}{{ end }} protocol: TCP - name: internal containerPort: {{ .Values.server.internalPort }} @@ -197,7 +251,7 @@ spec: {{- end }} {{- if or .Values.azurite.enabled .Values.credentials.existingSecret .Values.extraEnvFrom }} envFrom: - {{- if .Values.azurite.enabled }} + {{- if and .Values.azurite.enabled (not $dev) }} - secretRef: name: {{ include "celld.azurite.secretName" . }} {{- end }} @@ -209,10 +263,10 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} {{- end }} - {{- if or .Values.azurite.enabled $placeholder }} + {{- if or $dev .Values.azurite.enabled $placeholder }} startupProbe: httpGet: - path: /__celld/health + path: {{ $healthPath }} port: http periodSeconds: 2 timeoutSeconds: 2 @@ -220,7 +274,7 @@ spec: {{- end }} readinessProbe: httpGet: - path: /__celld/health + path: {{ $healthPath }} port: http initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }} periodSeconds: {{ .Values.probes.readiness.periodSeconds }} @@ -228,7 +282,7 @@ spec: failureThreshold: {{ .Values.probes.readiness.failureThreshold }} livenessProbe: httpGet: - path: /__celld/health + path: {{ $healthPath }} port: http initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }} periodSeconds: {{ .Values.probes.liveness.periodSeconds }} @@ -239,6 +293,14 @@ spec: mountPath: /var/lib/celld - name: tmp mountPath: /tmp + {{- if $dev }} + - name: esbuild + mountPath: /opt/esbuild + {{- if $devHost }} + - name: project + mountPath: {{ $devMount | quote }} + {{- end }} + {{- end }} {{- if include "celld.sharedCredentials.enabled" . }} {{- include "celld.sharedCredentials.volumeMount" . | nindent 12 }} {{- end }} @@ -249,6 +311,16 @@ spec: volumes: - name: tmp emptyDir: {} + {{- if $dev }} + - name: esbuild + emptyDir: {} + {{- if $devHost }} + - name: project + hostPath: + path: {{ $devHost | quote }} + type: Directory + {{- end }} + {{- end }} {{- if $placeholder }} - name: placeholder configMap: diff --git a/values.yaml b/values.yaml index 52d6d46..04e4d09 100644 --- a/values.yaml +++ b/values.yaml @@ -72,6 +72,18 @@ azurite: limits: memory: 256Mi +# celld dev: one local node, project store under .celld/dev, no fleet bucket. +# Mutually exclusive with azurite and a bucket. One replica. +dev: + enabled: false + # Node path of a Wrangler project. Empty uses the placeholder worker and --no-watch. + hostPath: "" + mountPath: /workspace + port: 8080 + logs: true + watch: true + clean: false + extraEnv: [] extraEnvFrom: []