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
82 changes: 42 additions & 40 deletions infra/environments/prod/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions infra/environments/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ resource "cloudflare_ruleset" "ssl_overrides" {
ssl = "strict"
}
},
{
description = "vault-strict-mode"
expression = "(http.host eq \"vault.gauchoracing.com\")"
action = "set_config"
enabled = true
action_parameters = {
ssl = "strict"
}
},
]
}

Expand Down
2 changes: 1 addition & 1 deletion infra/modules/eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 21.0"
version = "21.24.0"

name = var.name
kubernetes_version = var.kubernetes_version
Expand Down
2 changes: 1 addition & 1 deletion infra/modules/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 6.0"
version = "6.6.1"

name = var.name
cidr = var.cidr
Expand Down
23 changes: 23 additions & 0 deletions kubernetes/apps/vault.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: vault
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://github.com/Gaucho-Racing/infrastructure.git
targetRevision: main
path: kubernetes/manifests/vault
destination:
server: https://kubernetes.default.svc
namespace: vault
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- ServerSideApply=true
62 changes: 62 additions & 0 deletions kubernetes/manifests/vault/configmap-kerbecs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: kerbecs-config
namespace: vault
data:
kerbecs.yaml: |
gateway:
name: vault-gateway
version: 1.0.0
env: ${ENV:PROD}
timeouts:
dial: 5s
headers: 30s
idle: 50s
overall: 0

listeners:
gateway:
port: "10310"
cors:
enabled: true
allowed_origins: ["*"]
allow_credentials: false
admin:
port: "10300"
auth:
type: basic
username: ${KERBECS_USER:admin}
password: ${KERBECS_PASSWORD:admin}

providers:
static:
watch: true

upstreams:
vault:
name: vault
version: 1.0.0
instances:
- http://vault.vault.svc.cluster.local:9999

web:
name: vault-web
version: 1.0.0
instances:
- http://web.vault.svc.cluster.local:80

routes:
- name: vault-api
match:
path: /api/*
upstream: vault
rewrite:
strip_prefix: /api
envelope: passthrough

- name: vault-web
match:
path: /*
upstream: web
envelope: passthrough
30 changes: 30 additions & 0 deletions kubernetes/manifests/vault/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: vault
namespace: vault
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]'
alb.ingress.kubernetes.io/ssl-redirect: '443'
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/group.name: gr-prod
external-dns.alpha.kubernetes.io/hostname: vault.gauchoracing.com
external-dns.alpha.kubernetes.io/cloudflare-proxied: "true"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add vault to the Cloudflare strict-mode rules

This makes external-dns create a proxied Cloudflare record for vault.gauchoracing.com, but the only Cloudflare SSL overrides in infra/environments/prod/main.tf are for argocd, sentinel, and mapache, and that file documents that the zone defaults to Flexible while ALB-backed Ingresses here are HTTPS-only. For this new hostname Cloudflare will use the Flexible default against an Ingress that only declares an HTTPS listener, so the public Vault URL will hit the same redirect/522 failure unless a vault.gauchoracing.com strict-mode rule is added (or the record is not proxied).

Useful? React with 👍 / 👎.

spec:
ingressClassName: alb
tls:
- hosts:
- vault.gauchoracing.com
rules:
- host: vault.gauchoracing.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kerbecs
port:
number: 10310
74 changes: 74 additions & 0 deletions kubernetes/manifests/vault/kerbecs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kerbecs
namespace: vault
spec:
replicas: 1
selector:
matchLabels:
app: kerbecs
template:
metadata:
labels:
app: kerbecs
spec:
topologySpreadConstraints:
- maxSkew: 1
minDomains: 2
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: kerbecs
containers:
- name: kerbecs
image: bk1031/kerbecs:latest
ports:
- containerPort: 10310
name: gateway
- containerPort: 10300
name: admin
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
env:
- name: KERBECS_CONFIG
value: /etc/kerbecs/kerbecs.yaml
- name: ENV
value: PROD
- name: KERBECS_USER
value: admin
- name: KERBECS_PASSWORD
valueFrom:
secretKeyRef:
name: vault-secrets
key: KERBECS_PASSWORD
volumeMounts:
- name: kerbecs-config
mountPath: /etc/kerbecs
readOnly: true
volumes:
- name: kerbecs-config
configMap:
name: kerbecs-config
---
apiVersion: v1
kind: Service
metadata:
name: kerbecs
namespace: vault
spec:
selector:
app: kerbecs
ports:
- name: gateway
port: 10310
targetPort: 10310
- name: admin
port: 10300
targetPort: 10300
19 changes: 19 additions & 0 deletions kubernetes/manifests/vault/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- namespace.yaml
- configmap-kerbecs.yaml
- postgres.yaml
- kerbecs.yaml
- server.yaml
- web.yaml
- ingress.yaml

images:
- name: ghcr.io/gaucho-racing/vault-server
newTag: 1.0.0
- name: ghcr.io/gaucho-racing/vault-web
newTag: 1.0.0
- name: bk1031/kerbecs
newTag: 3.2.0
4 changes: 4 additions & 0 deletions kubernetes/manifests/vault/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: vault
8 changes: 8 additions & 0 deletions kubernetes/manifests/vault/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: vault
spec:
type: ExternalName
externalName: ec2-52-32-150-44.us-west-2.compute.amazonaws.com
Loading
Loading