Skip to content
simonkranPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Internal Developer Platform (IDP)

A comprehensive Kubernetes-based Internal Developer Platform providing multi-tenancy, GitOps, and security policies using Flux, Kyverno, and standard cluster addons.

Overview

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

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    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                    │
└─────────────────────────────────────────────────────────────┘

Directory Structure

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

Quick Start

Prerequisites

  • Kubernetes cluster (1.25+)
  • kubectl configured
  • Helm 3.x installed
  • GitHub account and repository
  • (Optional) DNS provider credentials for external-dns

Installation

  1. Fork/Clone this repository
git clone https://github.com/simonkran/idp-test.git
cd idp-test
  1. 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"
  1. Install Flux using Flux Operator
./platform/scripts/install-flux.sh

This 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
  1. Configure DNS and Certificate Email

Update the following files:

  • platform/infrastructure/cert-manager/clusterissuer.yaml - Update email addresses
  • platform/infrastructure/external-dns/helmrelease.yaml - Configure DNS provider
  1. 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 -A

Tenant Onboarding

Automated Onboarding

Use 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/apps

The script will:

  1. Create tenant directory with all necessary configurations
  2. Generate namespace, RBAC, quotas, network policies
  3. Set up Flux service account with least privilege
  4. Configure Git repository (if provided)
  5. Add tenant to main kustomization

Manual Onboarding

  1. Copy the template
cp -r platform/tenants/templates platform/tenants/team-name
  1. Replace placeholders

In all files under platform/tenants/team-name/, replace:

  • TENANT_NAME with your team name
  • TENANT_GIT_REPO_URL with the team's Git repository URL
  1. Add to kustomization

Edit platform/tenants/kustomization.yaml:

resources:
  - team-example
  - team-name  # Add this line
  1. Commit and push
git add platform/tenants/
git commit -m "Onboard team: team-name"
git push

Flux will automatically create the tenant namespace and all resources.

Tenant Configuration

Each tenant receives:

Namespace

  • Labeled with tenant name for easy identification
  • Pod Security Standards enforced (restricted)

Resource Quotas

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

Network Policies

  • Default deny all traffic
  • Allow traffic within namespace
  • Allow ingress from ingress-nginx
  • Allow DNS queries to kube-system
  • Allow external HTTPS/HTTP egress

RBAC

  • Admin service account with admin role
  • Viewer service account with view role
  • Support for user groups (OIDC/LDAP integration)

Flux GitOps

  • Dedicated Flux service account with namespace-scoped permissions
  • Git repository watching
  • Automatic reconciliation of tenant applications

Security Policies

The platform enforces the following Kyverno policies:

Multi-Tenancy

  • 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

Security

  • 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

Validation

  • validate-ingress: Ingress resources must have cert-manager annotations
  • require-labels: Common labels required for better organization (audit mode)

For Development Teams

Setting Up Your Applications

  1. Create a Git repository for your applications
mkdir my-team-apps
cd my-team-apps
git init
  1. 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
  1. Commit and push
git add .
git commit -m "Initial application deployment"
git push origin main
  1. Notify platform team

Provide your Git repository URL to the platform team, or update the flux-tenant.yaml yourself if you have access.

Important Requirements

Your applications must comply with platform policies:

  1. Use approved registries: docker.io, gcr.io, ghcr.io, quay.io, registry.k8s.io
  2. Run as non-root: Set securityContext.runAsNonRoot: true
  3. Define resource limits: All containers must have CPU and memory limits
  4. Use proper labels: Include app.kubernetes.io/name and app.kubernetes.io/instance
  5. Configure TLS: Ingresses must use cert-manager for certificates

Customization

Variable Substitution for Multi-Cluster Deployments

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.com

Available 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.

Adjusting Resource Quotas

Edit platform/tenants/<team-name>/resourcequota.yaml:

spec:
  hard:
    requests.cpu: "20"      # Increase CPU requests
    requests.memory: "40Gi" # Increase memory requests
    # ... other quotas

Adding Custom Policies

Create 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 pattern

External DNS Configuration

Update 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.com

Google Cloud DNS:

values:
  provider: google
  google:
    project: my-project
  domainFilters:
    - example.com

Cloudflare:

values:
  provider: cloudflare
  env:
    - name: CF_API_TOKEN
      valueFrom:
        secretKeyRef:
          name: cloudflare-api-token
          key: token
  domainFilters:
    - example.com

Monitoring and Observability

The 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:

  1. Install Prometheus and Grafana
  2. Enable ServiceMonitors in component values
  3. Create dashboards for platform metrics

Troubleshooting

Check Flux reconciliation

flux get all
flux logs

Check Kyverno policies

kubectl get clusterpolicies
kubectl describe clusterpolicy <policy-name>

View policy reports

kubectl get policyreports -A
kubectl describe policyreport -n <namespace> <report-name>

Check tenant resources

kubectl get all -n <tenant-namespace>
kubectl get resourcequota -n <tenant-namespace>
kubectl get networkpolicies -n <tenant-namespace>

Contributing

To contribute to the platform:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test in a development cluster
  5. Submit a pull request

License

This platform configuration is provided as-is for internal use.

Support

For platform support:

  • Create an issue in this repository
  • Contact the platform team at platform-team@example.com
  • Join the #platform-support Slack channel

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages