Skip to content

Commit

Permalink
Local Kind (#2801)
Browse files Browse the repository at this point in the history
* Add Flux v2.4.0 component manifests

* Add Flux v2.4.0 component manifests

* Add Flux sync manifests

* remove need for flux-system secret

* use public repo

* remove

* Setup kind infrastructure base

* move kind cluster config out of flux area

* Test redis deployment

* connect apps

* add minio

* connect minio

* connect minio in apps

* fix minio

* use updated docs for minio

* fix cluster issuance

* install trust manager

* make into a deployment

* remove unnecessary files

* centralize log handler setup

---------

Co-authored-by: Flux <>
  • Loading branch information
ravenac95 authored Jan 17, 2025
1 parent f7ebdd5 commit 9f76c17
Show file tree
Hide file tree
Showing 29 changed files with 530 additions and 10 deletions.
12 changes: 12 additions & 0 deletions ops/clusters/local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Local testing cluster

This is a local testing cluster that we can use to test trino and dagster
deployment.

## Setup

From the root of the repository run this command:

```bash
$ oso kind setup
```
19 changes: 19 additions & 0 deletions ops/clusters/local/apps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: local-apps
namespace: flux-system
spec:
dependsOn:
- name: infrastructure-controllers
interval: 1h
retryInterval: 1m
timeout: 5m
sourceRef:
kind: GitRepository
name: flux-system
path: ./ops/k8s-apps/local
force: true
prune: true
wait: true
16 changes: 16 additions & 0 deletions ops/clusters/local/infrastructure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: infrastructure-controllers
namespace: flux-system
spec:
interval: 1h
retryInterval: 1m
timeout: 5m
sourceRef:
kind: GitRepository
name: flux-system
path: ./ops/k8s-infrastructure/kind
prune: true
wait: true
2 changes: 1 addition & 1 deletion ops/clusters/warehouse/infrastructure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ spec:
sourceRef:
kind: GitRepository
name: flux-system
path: ./ops/k8s-infrastructure/controllers
path: ./ops/k8s-infrastructure/gke
prune: true
wait: true
7 changes: 7 additions & 0 deletions ops/k8s-apps/local/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./redis
- ./minio
- ./test
#- ./trino
6 changes: 6 additions & 0 deletions ops/k8s-apps/local/minio/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# We use minio to emulate an s3 storage for trino and iceberg
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: local-minio
resources:
- minio.yaml
90 changes: 90 additions & 0 deletions ops/k8s-apps/local/minio/minio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Intentionally the password is admin as this is for local testing.
---
apiVersion: v1
kind: Namespace
metadata:
name: local-minio
---
apiVersion: v1
kind: Secret
metadata:
name: minio-configuration
namespace: local-minio
type: Opaque
stringData:
config.env: |-
export MINIO_ROOT_USER="admin"
export MINIO_ROOT_PASSWORD="password"
export MINIO_STORAGE_CLASS_STANDARD="EC:0"
export MINIO_BROWSER="on"
---
apiVersion: v1
kind: Secret
metadata:
name: storage-user
namespace: local-minio
type: Opaque
data:
CONSOLE_ACCESS_KEY: c3RvcmFnZS11c2Vy # storage-user
CONSOLE_SECRET_KEY: cGFzc3dvcmQ= # password
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: tenant-certmanager-cert
namespace: local-minio
spec:
# If you see "Empty issuer DN not allowed in X509Certificates"
# You will need to add spec.subject.organizations or spec.commonName
# As documented in https://cert-manager.io/docs/usage/certificate/
# This specially if your other apps can't trust MinIO cert issued by cert-manager
# Example
#
# subject:
# organizations:
# - jetstack
# commonName: minio.local-minio.svc.cluster.local
dnsNames:
- "minio.local-minio"
- "minio.local-minio.svc"
- "minio.local-minio.svc.cluster.local"
- "*.local-minio.svc.cluster.local"
- "*.minio.local-minio.svc.cluster.local"
secretName: local-minio-tls
issuerRef:
name: cluster-ca
kind: ClusterIssuer
group: cert-manager.io
---
apiVersion: minio.min.io/v2
kind: Tenant
metadata:
name: minio-configuration
namespace: local-minio
spec:
image: quay.io/minio/minio:RELEASE.2024-11-07T00-52-20Z
mountPath: /export
imagePullPolicy: IfNotPresent
pools:
- name: pool-0
servers: 1
volumeClaimTemplate:
metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "1Gi"
storageClassName: standard
volumesPerServer: 1
requestAutoCert: false
## Secret with credentials and configurations to be used by MinIO Tenant.
configuration:
name: minio-configuration
users:
- name: storage-user
externalCertSecret:
- name: local-minio-tls
type: cert-manager.io/v1
9 changes: 9 additions & 0 deletions ops/k8s-apps/local/redis/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/redis
namespace: local-redis
patches:
- path: redis-deployment.yaml
target:
kind: Deployment
24 changes: 24 additions & 0 deletions ops/k8s-apps/local/redis/redis-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:latest
ports:
- containerPort: 6379
env:
- name: REDIS_MAXMEMORY
value: "20mb"
- name: REDIS_MAXMEMORY_POLICY
value: "allkeys-lru"
1 change: 1 addition & 0 deletions ops/k8s-apps/local/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# A testing pod that runs forever
5 changes: 5 additions & 0 deletions ops/k8s-apps/local/test/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: test
resources:
- pod.yaml
39 changes: 39 additions & 0 deletions ops/k8s-apps/local/test/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: test
labels:
opensource.observer/cert-inject: "enabled"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
spec:
replicas: 1
selector:
matchLabels:
app: test-pod
template:
metadata:
labels:
app: test-pod
spec:
containers:
- name: test-pod
image: ubuntu
command: ["bash", "-c", "while true; do sleep 30; done;" ]
volumeMounts:
- mountPath: /etc/ssl/certs/
name: cluster-self-signed-bundle
readOnly: true
volumes:
- name: cluster-self-signed-bundle
configMap:
name: cluster-self-signed-bundle
defaultMode: 0644
optional: false
items:
- key: ca-certificates.crt
path: ca-certificates.crt
8 changes: 8 additions & 0 deletions ops/k8s-apps/local/trino/custom-helm-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: production-trino
spec:
values:
serviceAccount:
name: production-trino
11 changes: 11 additions & 0 deletions ops/k8s-apps/local/trino/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/trino
namespace: local-trino
patches:
- path: ./custom-helm-values.yaml
target:
kind: HelmRelease
options:
allowNameChange: true
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: cert-manager
name: jetstack
namespace: cert-manager
spec:
interval: 24h
Expand All @@ -29,8 +29,25 @@ spec:
version: "1.x"
sourceRef:
kind: HelmRepository
name: cert-manager
name: jetstack
namespace: cert-manager
interval: 12h
values:
installCRDs: true
installCRDs: true
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: trust-manager
namespace: cert-manager
spec:
interval: 30m
chart:
spec:
chart: trust-manager
version: "*"
sourceRef:
kind: HelmRepository
name: jetstack
namespace: cert-manager
interval: 12h
65 changes: 65 additions & 0 deletions ops/k8s-infrastructure/common/self-signed-certs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: self-signed-root
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: self-signed-ca
namespace: cert-manager
spec:
isCA: true
commonName: self-signed-ca
secretName: self-signed-root-secret
privateKey:
algorithm: ECDSA
size: 256
issuerRef:
name: self-signed-root
kind: ClusterIssuer
group: cert-manager.io
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: cluster-ca
spec:
ca:
secretName: self-signed-root-secret
---
apiVersion: trust.cert-manager.io/v1alpha1
kind: Bundle
metadata:
name: cluster-self-signed-bundle # The bundle name will also be used for the target
spec:
sources:
# Include a bundle of publicly trusted certificates which can be
# used to validate most TLS certificates on the internet, such as
# those issued by Let's Encrypt, Google, Amazon and others.
- useDefaultCAs: true

# A Secret in the "trust" namespace; see "Trust Namespace" below for further details
- secret:
name: self-signed-root-secret
key: "ca.crt"

target:
# Sync the bundle to a ConfigMap called `my-org.com` in every namespace which
# has the label "linkerd.io/inject=enabled"
# All ConfigMaps will include a PEM-formatted bundle, here named "root-certs.pem"
# and in this case we also request binary formatted bundles in JKS and PKCS#12 formats,
# here named "bundle.jks" and "bundle.p12".
configMap:
key: "ca-certificates.crt"
additionalFormats:
jks:
key: "ca-certificates.jks"
pkcs12:
key: "ca-certificates.p12"
namespaceSelector:
matchLabels:
opensource.observer/cert-inject: "enabled"
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cert-manager.yaml
- ../common/cert-manager.yaml
- ../common/self-signed-certs.yaml
- kube-secrets-init.yaml
- ingress-internal-cloudflare.yaml
- cloudsql-proxy-operator.yaml
Loading

0 comments on commit 9f76c17

Please sign in to comment.