A comprehensive Kubernetes-based Internal Developer Platform providing multi-tenancy, GitOps, and security policies using Flux, Kyverno, and standard cluster addons.
This platform provides:
- Multi-Tenancy: Isolated namespaces for teams with resource quotas and network policies
- GitOps: Flux-based continuous delivery for infrastructure and applications
- Security: Kyverno policies enforcing security best practices and tenant isolation
- Standard Addons: Ingress (nginx), cert-manager, external-dns
- Easy Onboarding: Automated tenant provisioning with scripts
- Variable Substitution: Environment-agnostic manifests with cluster-specific configuration injection
┌─────────────────────────────────────────────────────────────┐
│ Kubernetes Cluster │
├─────────────────────────────────────────────────────────────┤
│ Platform Layer (flux-system namespace) │
│ ├── Flux Operator (GitOps reconciliation) │
│ └── Platform GitRepository │
├─────────────────────────────────────────────────────────────┤
│ Infrastructure Layer │
│ ├── Kyverno (Policy Engine) │
│ ├── Ingress-nginx (Ingress Controller) │
│ ├── cert-manager (Certificate Management) │
│ └── external-dns (DNS Management) │
├─────────────────────────────────────────────────────────────┤
│ Policy Layer │
│ ├── Multi-tenancy policies │
│ ├── Security policies │
│ └── Validation policies │
├─────────────────────────────────────────────────────────────┤
│ Tenant Layer (per tenant namespace) │
│ ├── Namespace with labels │
│ ├── Resource Quotas │
│ ├── Network Policies │
│ ├── RBAC (ServiceAccounts, RoleBindings) │
│ ├── Flux Service Account │
│ └── Tenant GitRepository → Applications │
└─────────────────────────────────────────────────────────────┘
platform/
├── bootstrap/ # Flux bootstrap configuration
│ ├── flux-operator-values.yaml # Helm values for Flux Operator
│ ├── flux-instance.yaml # FluxInstance resource
│ ├── runtime-info.yaml # Cluster metadata ConfigMap
│ ├── flux-system.yaml # Legacy Flux resources
│ └── README.md
├── infrastructure/ # Platform infrastructure components
│ ├── flux-system/ # Helm repositories
│ ├── kyverno/ # Policy engine
│ ├── ingress-nginx/ # Ingress controller
│ ├── cert-manager/ # Certificate management
│ └── external-dns/ # DNS automation
├── policies/ # Kyverno policies
│ ├── multi-tenancy/ # Tenant isolation policies
│ ├── security/ # Security policies
│ └── validation/ # Resource validation
├── tenants/ # Tenant configurations
│ ├── templates/ # Templates for new tenants
│ └── team-example/ # Example tenant
├── examples/ # Usage examples
│ ├── variable-substitution-example.yaml
│ └── README.md
└── scripts/ # Automation scripts
├── install-flux.sh # Flux Operator installation
├── onboard-tenant.sh # Tenant onboarding
└── verify-platform.sh # Platform verification
- Kubernetes cluster (1.25+)
- kubectl configured
- Helm 3.x installed
- GitHub account and repository
- (Optional) DNS provider credentials for external-dns
- Fork/Clone this repository
git clone https://github.com/simonkran/idp-test.git
cd idp-test- Configure Git Repository
Update platform/bootstrap/flux-instance.yaml with your Git repository:
sync:
url: "https://github.com/YOUR_ORG/idp-test"
ref: "refs/heads/main"- Install Flux using Flux Operator
./platform/scripts/install-flux.shThis script will:
- Install Flux Operator via Helm
- Apply FluxInstance resource
- Wait for all Flux components to be ready
Manual Installation:
If you prefer manual steps:
# Add Helm repository
helm repo add flux-operator https://controlplane.io/helm-charts
helm repo update
# Install Flux Operator
helm upgrade --install flux-operator flux-operator/flux-operator \
--namespace flux-system \
--create-namespace \
--values platform/bootstrap/flux-operator-values.yaml \
--wait
# Apply FluxInstance
kubectl apply -f platform/bootstrap/flux-instance.yaml- Configure DNS and Certificate Email
Update the following files:
platform/infrastructure/cert-manager/clusterissuer.yaml- Update email addressesplatform/infrastructure/external-dns/helmrelease.yaml- Configure DNS provider
- Verify installation
./platform/scripts/verify-platform.sh
# Or manually check:
kubectl get fluxinstance -n flux-system
kubectl get kustomizations -n flux-system
kubectl get helmreleases -AUse the provided script to onboard a new tenant:
# Basic onboarding (without Git repo)
./platform/scripts/onboard-tenant.sh team-alpha
# With Git repository
./platform/scripts/onboard-tenant.sh team-alpha https://github.com/team-alpha/appsThe script will:
- Create tenant directory with all necessary configurations
- Generate namespace, RBAC, quotas, network policies
- Set up Flux service account with least privilege
- Configure Git repository (if provided)
- Add tenant to main kustomization
- Copy the template
cp -r platform/tenants/templates platform/tenants/team-name- Replace placeholders
In all files under platform/tenants/team-name/, replace:
TENANT_NAMEwith your team nameTENANT_GIT_REPO_URLwith the team's Git repository URL
- Add to kustomization
Edit platform/tenants/kustomization.yaml:
resources:
- team-example
- team-name # Add this line- Commit and push
git add platform/tenants/
git commit -m "Onboard team: team-name"
git pushFlux will automatically create the tenant namespace and all resources.
Each tenant receives:
- Labeled with tenant name for easy identification
- Pod Security Standards enforced (restricted)
Default quotas (adjustable):
- CPU requests: 10 cores
- Memory requests: 20Gi
- CPU limits: 20 cores
- Memory limits: 40Gi
- Persistent Volume Claims: 10
- Load Balancers: 2
- Ingresses: 10
- Default deny all traffic
- Allow traffic within namespace
- Allow ingress from ingress-nginx
- Allow DNS queries to kube-system
- Allow external HTTPS/HTTP egress
- Admin service account with admin role
- Viewer service account with view role
- Support for user groups (OIDC/LDAP integration)
- Dedicated Flux service account with namespace-scoped permissions
- Git repository watching
- Automatic reconciliation of tenant applications
The platform enforces the following Kyverno policies:
- require-tenant-label: All managed namespaces must have a tenant label
- restrict-namespace-creation: Only platform team can create namespaces
- isolate-tenant-resources: Prevents creation of cluster-scoped resources by tenants
- restrict-image-registries: Only approved container registries allowed
- require-non-root: Containers must run as non-root user
- disallow-privileged: Privileged containers not allowed
- require-resource-limits: All containers must have CPU/memory limits
- validate-ingress: Ingress resources must have cert-manager annotations
- require-labels: Common labels required for better organization (audit mode)
- Create a Git repository for your applications
mkdir my-team-apps
cd my-team-apps
git init- Create your application manifests
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
namespace: my-team
labels:
app.kubernetes.io/name: my-app
app.kubernetes.io/instance: my-app-prod
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
containers:
- name: my-app
image: gcr.io/my-org/my-app:v1.0.0
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: my-app
namespace: my-team
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app
namespace: my-team
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: nginx
tls:
- hosts:
- my-app.example.com
secretName: my-app-tls
rules:
- host: my-app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80- Commit and push
git add .
git commit -m "Initial application deployment"
git push origin main- Notify platform team
Provide your Git repository URL to the platform team, or update the flux-tenant.yaml yourself if you have access.
Your applications must comply with platform policies:
- Use approved registries: docker.io, gcr.io, ghcr.io, quay.io, registry.k8s.io
- Run as non-root: Set
securityContext.runAsNonRoot: true - Define resource limits: All containers must have CPU and memory limits
- Use proper labels: Include
app.kubernetes.io/nameandapp.kubernetes.io/instance - Configure TLS: Ingresses must use cert-manager for certificates
The platform uses Flux post-build variable substitution to inject cluster-specific configuration at deployment time. This allows you to write environment-agnostic manifests that work across multiple clusters.
Runtime Configuration (platform/bootstrap/runtime-info.yaml):
data:
cluster_name: "production-us-east-1"
cluster_env: "production"
cluster_region: "us-east-1"
base_domain: "example.com"
cluster_domain: "prod.example.com"
default_replica_count: "2"
platform_team_email: "platform-team@example.com"Usage in manifests:
# Deployment with environment-specific labels
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
environment: ${cluster_env}
cluster: ${cluster_name}
spec:
replicas: ${default_replica_count}
template:
spec:
containers:
- name: app
env:
- name: CLUSTER_NAME
value: "${cluster_name}"
---
# Ingress with dynamic domain
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app
spec:
rules:
- host: my-app.${cluster_domain} # Becomes: my-app.prod.example.comAvailable variables: cluster_name, cluster_env, cluster_region, cluster_provider, base_domain, cluster_domain, default_replica_count, enable_autoscaling, enable_monitoring, platform_team_email
See platform/examples/variable-substitution-example.yaml for complete examples.
Edit platform/tenants/<team-name>/resourcequota.yaml:
spec:
hard:
requests.cpu: "20" # Increase CPU requests
requests.memory: "40Gi" # Increase memory requests
# ... other quotasCreate new Kyverno policies in platform/policies/:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: my-custom-policy
spec:
validationFailureAction: Enforce
rules:
- name: my-rule
match:
any:
- resources:
kinds:
- Pod
validate:
message: "Custom validation message"
pattern:
# Your validation patternUpdate platform/infrastructure/external-dns/helmrelease.yaml based on your DNS provider:
AWS Route53:
values:
provider: aws
aws:
region: us-east-1
zoneType: public
domainFilters:
- example.comGoogle Cloud DNS:
values:
provider: google
google:
project: my-project
domainFilters:
- example.comCloudflare:
values:
provider: cloudflare
env:
- name: CF_API_TOKEN
valueFrom:
secretKeyRef:
name: cloudflare-api-token
key: token
domainFilters:
- example.comThe platform includes basic metrics endpoints:
- Ingress-nginx metrics:
http://<ingress-controller-ip>:10254/metrics - Kyverno metrics: Available via ServiceMonitor if Prometheus is installed
To add full observability:
- Install Prometheus and Grafana
- Enable ServiceMonitors in component values
- Create dashboards for platform metrics
flux get all
flux logskubectl get clusterpolicies
kubectl describe clusterpolicy <policy-name>kubectl get policyreports -A
kubectl describe policyreport -n <namespace> <report-name>kubectl get all -n <tenant-namespace>
kubectl get resourcequota -n <tenant-namespace>
kubectl get networkpolicies -n <tenant-namespace>To contribute to the platform:
- Fork the repository
- Create a feature branch
- Make your changes
- Test in a development cluster
- Submit a pull request
This platform configuration is provided as-is for internal use.
For platform support:
- Create an issue in this repository
- Contact the platform team at platform-team@example.com
- Join the #platform-support Slack channel