diff --git a/README.md b/README.md index 4cea4c8..cd839ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # cursor-devbox -Personal Cursor Remote-SSH workspace image and GitOps for **node1-k3s**. +Personal Cursor Remote-SSH workspace image and GitOps for **node1-k3s** and a second home on **node4-k3s**. - **Image**: `dcr.trinitysan.by/infra/cursor-devbox` - **Deploy**: `deploy/` (Namespace, StatefulSet, ingress) @@ -12,8 +12,10 @@ Infra on node1 only keeps thin Flux glue (`GitRepository` + Kustomizations + aut | Endpoint | Detail | |----------|--------| -| SSH | `ssh -p 2222 developer@devbox.trinitysan.by` | -| HTTP health | `https://devbox.trinitysan.by/` | +| SSH (node1) | `ssh -p 2222 developer@devbox.trinitysan.by` | +| HTTP health (node1) | `https://devbox.trinitysan.by/` | +| SSH (node4) | `ssh -p 2222 developer@box2.trinitysan.by` | +| HTTP health (node4) | `https://box2.trinitysan.by/` | ## CI diff --git a/deploy-node4/010-namespace-secrets.yaml b/deploy-node4/010-namespace-secrets.yaml new file mode 100644 index 0000000..01d6b02 --- /dev/null +++ b/deploy-node4/010-namespace-secrets.yaml @@ -0,0 +1,61 @@ +# Namespace, DCR pull secret, SSH allowlist, Service. +# Reconciled by Flux Kustomization cursor-devbox (path ./deploy-node4) on node4-k3s. + +--- +apiVersion: v1 +kind: Namespace +metadata: + name: cursor-devbox + labels: + name: cursor-devbox + annotations: + linkerd.io/inject: disabled + +--- +# Replicate federated DCR RO credentials for kubelet imagePullSecrets. +apiVersion: secret-adapter.trinitysan.by/v1 +kind: SecretAdapter +metadata: + name: dcr-registry-auth-ro + namespace: cursor-devbox +spec: + name: dcr-registry-auth-ro + namespace: cursor-devbox + type: kubernetes.io/dockerconfigjson + waitForSources: true + syncInterval: 60 + stringData: + .dockerconfigjson: ${federated-secrets.dcr-registry-auth-ro.".dockerconfigjson"} + +--- +# Hardcoded allowlist: laptop SSH public keys (not secrets). +apiVersion: v1 +kind: ConfigMap +metadata: + name: cursor-devbox-authorized-keys + namespace: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caD/8f2Lr8CcFCN5pcG020gvLSVdok71dB27NQ/2HOax1i0WQTZVjDrL6kMwRb37njr/k= svv@LAPTOP-08PG1IL5 + +--- +apiVersion: v1 +kind: Service +metadata: + name: cursor-devbox + namespace: cursor-devbox + annotations: + service.kubernetes.io/topology-mode: Auto +spec: + selector: + app: cursor-devbox + ports: + - name: ssh + port: 22 + targetPort: ssh + protocol: TCP + - name: http + port: 8080 + targetPort: http + protocol: TCP diff --git a/deploy-node4/020-statefulset.yaml b/deploy-node4/020-statefulset.yaml new file mode 100644 index 0000000..a2d2ed4 --- /dev/null +++ b/deploy-node4/020-statefulset.yaml @@ -0,0 +1,119 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: cursor-devbox + namespace: cursor-devbox +spec: + serviceName: cursor-devbox + replicas: 1 + selector: + matchLabels: + app: cursor-devbox + template: + metadata: + labels: + app: cursor-devbox + annotations: + linkerd.io/inject: disabled + spec: + terminationGracePeriodSeconds: 30 + imagePullSecrets: + - name: dcr-registry-auth-ro + containers: + - name: ssh + image: dcr.trinitysan.by/infra/cursor-devbox:10-90c6b6c4250a68f4cb654bc18e52f2a47f9dc3a4 # {"$imagepolicy": "flux-system:cursor-devbox"} + imagePullPolicy: IfNotPresent + ports: + - name: ssh + containerPort: 22 + - name: http + containerPort: 8080 + env: + - name: DOCKER_HOST + value: tcp://127.0.0.1:2375 + - name: HOME + value: /home/developer + - name: HTTP_PROXY + value: socks5h://node2-socks5.egress-proxy.svc.clusterset.local:1080 + - name: HTTPS_PROXY + value: socks5h://node2-socks5.egress-proxy.svc.clusterset.local:1080 + - name: NO_PROXY + value: localhost,127.0.0.1,::1,.svc,.svc.cluster.local,.svc.clusterset.local,.trinitysan.by,107.155.122.141,107.155.122.212,63.250.53.80,91.210.106.53,10.0.0.0/8,10.32.0.0/12,10.43.0.0/16,10.51.0.0/16,10.53.0.0/16 + securityContext: + allowPrivilegeEscalation: true + capabilities: + add: + - SYS_PTRACE + resources: + requests: + cpu: "750m" + memory: 3Gi + limits: + cpu: "4" + memory: 8Gi + # startupProbe covers slow first boot (sshd after host-key/auth setup). + startupProbe: + tcpSocket: + port: ssh + failureThreshold: 60 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: ssh + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: ssh + periodSeconds: 20 + volumeMounts: + - name: home + mountPath: /home/developer + subPath: home + - name: authorized-keys + mountPath: /etc/ssh-authorized-keys + readOnly: true + - name: dind + image: docker:27-dind + imagePullPolicy: IfNotPresent + args: + - --host=tcp://0.0.0.0:2375 + - --tls=false + env: + - name: DOCKER_TLS_CERTDIR + value: "" + securityContext: + privileged: true + resources: + requests: + cpu: "250m" + memory: 1Gi + limits: + cpu: "2" + memory: 4Gi + readinessProbe: + tcpSocket: + port: 2375 + initialDelaySeconds: 5 + periodSeconds: 10 + volumeMounts: + - name: home + mountPath: /var/lib/docker + subPath: docker + - name: dind-run + mountPath: /var/run + volumes: + - name: authorized-keys + configMap: + name: cursor-devbox-authorized-keys + - name: dind-run + emptyDir: {} + volumeClaimTemplates: + - metadata: + name: home + spec: + accessModes: + - ReadWriteOnce + storageClassName: local-storage + resources: + requests: + storage: 30Gi diff --git a/deploy-node4/030-ingress.yaml b/deploy-node4/030-ingress.yaml new file mode 100644 index 0000000..8a6864a --- /dev/null +++ b/deploy-node4/030-ingress.yaml @@ -0,0 +1,32 @@ +# Traefik TCP SSH + TrinityIngress HTTP health on node4 (box2.trinitysan.by). + +--- +# Traefik TCP :2222 → OpenSSH in the pod (plain SSH; HostSNI catch-all). +apiVersion: traefik.io/v1alpha1 +kind: IngressRouteTCP +metadata: + name: cursor-devbox-ssh + namespace: cursor-devbox +spec: + entryPoints: + - ssh + routes: + - match: HostSNI(`*`) + services: + - name: cursor-devbox + port: 22 + +--- +# DNS A record + HTTPS front for the tiny HTTP health page; SSH uses Traefik TCP :2222. +apiVersion: ingress.trinitysan.by/v1 +kind: TrinityIngress +metadata: + name: cursor-devbox + namespace: cursor-devbox +spec: + hostname: box2.trinitysan.by + serviceRef: + namespace: cursor-devbox + name: cursor-devbox + port: 8080 + certificateReclaimPolicy: Retain diff --git a/deploy-node4/kustomization.yaml b/deploy-node4/kustomization.yaml new file mode 100644 index 0000000..abf2bcd --- /dev/null +++ b/deploy-node4/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - 010-namespace-secrets.yaml + - 020-statefulset.yaml + - 030-ingress.yaml diff --git a/flux/image-automation.yaml b/flux/image-automation.yaml index eed7b1e..c751da4 100644 --- a/flux/image-automation.yaml +++ b/flux/image-automation.yaml @@ -1,6 +1,7 @@ # Flux image automation for cursor-devbox (applied into flux-system on node1). # GitRepository cursor-devbox is defined in infra glue (130-cursor-devbox.yaml). # CI tags: latest, , - — policy elects the last form. +# Setters scan the whole repo so both deploy/ and deploy-node4/ stay on the elected tag. --- apiVersion: image.toolkit.fluxcd.io/v1 @@ -56,5 +57,5 @@ spec: push: branch: master update: - path: ./deploy + path: . strategy: Setters