feat(url-shortener): add deployment manifests and Tekton CI

This commit is contained in:
dahyeon committed 2026-11-04 04:56:48 +09:00
1 parent 176c214f86
commit d909a86b0e
24 files changed
+1432

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
# URL shortener
- 환경: `overlays/staging`, `overlays/prod`
- 이미지: `registry.dahyeon.us/dahyeon/url-shortener`
- Harbor pull Secret: `harbor-registry`
- 앱 Secret: `url-shortener-secrets` (Infisical)
+89
View File
@@ -0,0 +1,89 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: url-shortener
labels:
app.kubernetes.io/component: app
spec:
replicas: 0
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app.kubernetes.io/name: url-shortener
app.kubernetes.io/component: app
template:
metadata:
labels:
app.kubernetes.io/name: url-shortener
app.kubernetes.io/component: app
spec:
serviceAccountName: url-shortener
automountServiceAccountToken: false
imagePullSecrets:
- name: harbor-registry
terminationGracePeriodSeconds: 120
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
fsGroup: 65532
seccompProfile:
type: RuntimeDefault
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: url-shortener
app.kubernetes.io/component: app
topologyKey: kubernetes.io/hostname
containers:
- name: app
image: registry.dahyeon.us/dahyeon/url-shortener
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
envFrom:
- configMapRef:
name: url-shortener-config
- secretRef:
name: url-shortener-secrets
ports:
- name: http
containerPort: 3000
protocol: TCP
startupProbe:
httpGet:
path: /health/live
port: http
periodSeconds: 5
failureThreshold: 24
livenessProbe:
httpGet:
path: /health/live
port: http
periodSeconds: 15
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /health/ready
port: http
periodSeconds: 10
timeoutSeconds: 3
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: "1"
memory: 512Mi
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- services.yaml
- serviceaccount.yaml
- poddisruptionbudget.yaml
labels:
- includeSelectors: true
pairs:
app.kubernetes.io/name: url-shortener
app.kubernetes.io/part-of: url-shortener
app.kubernetes.io/managed-by: kustomize
@@ -0,0 +1,10 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: url-shortener
spec:
minAvailable: 1
selector:
matchLabels:
app.kubernetes.io/name: url-shortener
app.kubernetes.io/component: app
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: url-shortener
automountServiceAccountToken: false
+14
View File
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: url-shortener
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: url-shortener
app.kubernetes.io/component: app
ports:
- name: http
port: 3000
targetPort: http
protocol: TCP
@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: url-shortener-config
data:
APP_ENV: prod
HOST: 0.0.0.0
PORT: "3000"
DEV_AUTH_ENABLED: "false"
APP_ORIGIN: https://urls.dahyeon.us
API_ORIGIN: https://urls-api.dahyeon.us
SHORT_ORIGIN: https://rabbitma.us
SESSION_HOURS: "8"
# Set during promotion; database ID must match deploy/cloudflare/prod.json in the source revision.
CLOUDFLARE_ACCOUNT_ID: ""
CLOUDFLARE_D1_DATABASE_ID: ""
PUBLISH_WAIT_MS: "1500"
JOB_POLL_MS: "1000"
STATS_INTERVAL_MS: "60000"
API_RATE_LIMIT: "300"
@@ -0,0 +1,9 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: url-shortener
spec:
template:
metadata:
labels:
app.kubernetes.io/environment: prod
@@ -0,0 +1,38 @@
apiVersion: secrets.infisical.com/v1beta1
kind: InfisicalStaticSecret
metadata:
name: url-shortener-secrets
spec:
infisicalAuthRef:
name: infisical-auth
namespace: infisical
syncOptions:
refreshInterval: 60s
instantUpdates: false
sources:
- projectId: 01c4ebe5-8c73-475c-ba29-56709483b0f1
environmentSlug: prod
secretPath: /
recursive: false
targets:
- name: url-shortener-secrets
namespace: url-shortener-prod
kind: Secret
creationPolicy: Owner
secretType: Opaque
template:
engineVersion: v1
data:
MONGODB_CONNECTION_STRING: "{{ .MONGODB_CONNECTION_STRING.Value }}"
MICROSOFT_ENTRAID_TENANT_ID: "{{ .MICROSOFT_ENTRAID_TENANT_ID.Value }}"
MICROSOFT_ENTRAID_CLIENT_ID: "{{ .MICROSOFT_ENTRAID_CLIENT_ID.Value }}"
MICROSOFT_ENTRAID_CLIENT_SECRET: "{{ .MICROSOFT_ENTRAID_CLIENT_SECRET.Value }}"
MICROSOFT_ENTRAID_BOOTSTRAP_ADMIN_OIDS: "{{ .MICROSOFT_ENTRAID_BOOTSTRAP_ADMIN_OIDS.Value }}"
CLOUDFLARE_D1_API_TOKEN: "{{ .CLOUDFLARE_D1_API_TOKEN.Value }}"
INGEST_HMAC_SECRET: "{{ .INGEST_HMAC_SECRET.Value }}"
NEW_RELIC_LICENSE_KEY: "{{ .NEW_RELIC_LICENSE_KEY.Value }}"
MONGODB_DATABASE: "{{ .MONGODB_DATABASE.Value }}"
LOG_LEVEL: "{{ .LOG_LEVEL.Value }}"
NEW_RELIC_APP_NAME: "{{ .NEW_RELIC_APP_NAME.Value }}"
NEW_RELIC_ENABLED: "{{ .NEW_RELIC_ENABLED.Value }}"
NEW_RELIC_LOG_LEVEL: "{{ .NEW_RELIC_LOG_LEVEL.Value }}"
@@ -0,0 +1,44 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: url-shortener-api
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: haproxy
tls:
- hosts:
- urls-api.dahyeon.us
secretName: url-shortener-api-prod-tls
rules:
- host: urls-api.dahyeon.us
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: url-shortener
port:
number: 3000
- path: /auth
pathType: Prefix
backend:
service:
name: url-shortener
port:
number: 3000
- path: /service/v1
pathType: Prefix
backend:
service:
name: url-shortener
port:
number: 3000
- path: /ingest/v1/clicks
pathType: Exact
backend:
service:
name: url-shortener
port:
number: 3000
@@ -0,0 +1,17 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: url-shortener-prod
resources:
- ../../base
- configmap.yaml
- infisical-secret.yaml
- ingress.yaml
images:
- name: registry.dahyeon.us/dahyeon/url-shortener
newName: registry.dahyeon.us/dahyeon/url-shortener
newTag: bootstrap
replicas:
- name: url-shortener
count: 0
patches:
- path: deployment-patch.yaml
@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: url-shortener-config
data:
APP_ENV: staging
HOST: 0.0.0.0
PORT: "3000"
DEV_AUTH_ENABLED: "false"
APP_ORIGIN: https://urls-staging.dahyeon.us
API_ORIGIN: https://urls-api-staging.dahyeon.us
SHORT_ORIGIN: https://staging.rabbitma.us
SESSION_HOURS: "8"
# Tekton copies these public identifiers from its Cloudflare account and the source D1 profile.
CLOUDFLARE_ACCOUNT_ID: ""
CLOUDFLARE_D1_DATABASE_ID: ""
PUBLISH_WAIT_MS: "1500"
JOB_POLL_MS: "1000"
STATS_INTERVAL_MS: "60000"
API_RATE_LIMIT: "300"
@@ -0,0 +1,9 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: url-shortener
spec:
template:
metadata:
labels:
app.kubernetes.io/environment: staging
@@ -0,0 +1,38 @@
apiVersion: secrets.infisical.com/v1beta1
kind: InfisicalStaticSecret
metadata:
name: url-shortener-secrets
spec:
infisicalAuthRef:
name: infisical-auth
namespace: infisical
syncOptions:
refreshInterval: 60s
instantUpdates: false
sources:
- projectId: 01c4ebe5-8c73-475c-ba29-56709483b0f1
environmentSlug: staging
secretPath: /
recursive: false
targets:
- name: url-shortener-secrets
namespace: url-shortener-staging
kind: Secret
creationPolicy: Owner
secretType: Opaque
template:
engineVersion: v1
data:
MONGODB_CONNECTION_STRING: "{{ .MONGODB_CONNECTION_STRING.Value }}"
MICROSOFT_ENTRAID_TENANT_ID: "{{ .MICROSOFT_ENTRAID_TENANT_ID.Value }}"
MICROSOFT_ENTRAID_CLIENT_ID: "{{ .MICROSOFT_ENTRAID_CLIENT_ID.Value }}"
MICROSOFT_ENTRAID_CLIENT_SECRET: "{{ .MICROSOFT_ENTRAID_CLIENT_SECRET.Value }}"
MICROSOFT_ENTRAID_BOOTSTRAP_ADMIN_OIDS: "{{ .MICROSOFT_ENTRAID_BOOTSTRAP_ADMIN_OIDS.Value }}"
CLOUDFLARE_D1_API_TOKEN: "{{ .CLOUDFLARE_D1_API_TOKEN.Value }}"
INGEST_HMAC_SECRET: "{{ .INGEST_HMAC_SECRET.Value }}"
NEW_RELIC_LICENSE_KEY: "{{ .NEW_RELIC_LICENSE_KEY.Value }}"
MONGODB_DATABASE: "{{ .MONGODB_DATABASE.Value }}"
LOG_LEVEL: "{{ .LOG_LEVEL.Value }}"
NEW_RELIC_APP_NAME: "{{ .NEW_RELIC_APP_NAME.Value }}"
NEW_RELIC_ENABLED: "{{ .NEW_RELIC_ENABLED.Value }}"
NEW_RELIC_LOG_LEVEL: "{{ .NEW_RELIC_LOG_LEVEL.Value }}"
@@ -0,0 +1,44 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: url-shortener-api
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: haproxy
tls:
- hosts:
- urls-api-staging.dahyeon.us
secretName: url-shortener-api-staging-tls
rules:
- host: urls-api-staging.dahyeon.us
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: url-shortener
port:
number: 3000
- path: /auth
pathType: Prefix
backend:
service:
name: url-shortener
port:
number: 3000
- path: /service/v1
pathType: Prefix
backend:
service:
name: url-shortener
port:
number: 3000
- path: /ingest/v1/clicks
pathType: Exact
backend:
service:
name: url-shortener
port:
number: 3000
@@ -0,0 +1,17 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: url-shortener-staging
resources:
- ../../base
- configmap.yaml
- infisical-secret.yaml
- ingress.yaml
images:
- name: registry.dahyeon.us/dahyeon/url-shortener
newName: registry.dahyeon.us/dahyeon/url-shortener
newTag: bootstrap
replicas:
- name: url-shortener
count: 0
patches:
- path: deployment-patch.yaml