kustomize
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
# Git-managed K3s configuration
|
||||
|
||||
This directory contains the Kubernetes resources that are safe to keep in Git.
|
||||
The intended ownership boundary is:
|
||||
|
||||
- Ansible or the K3s install script bootstraps the cluster and installs Flux.
|
||||
- Flux reconciles `k3s_rencher/`.
|
||||
- `infrastructure/` contains shared cluster defaults.
|
||||
- `apps/` contains workload definitions.
|
||||
- Secrets are encrypted with SOPS or supplied by an external secrets manager.
|
||||
|
||||
## Bootstrap resources
|
||||
|
||||
The cluster configuration is `k3s_rencher/`. Render it before applying:
|
||||
|
||||
```sh
|
||||
kubectl kustomize k3s_rencher
|
||||
kubectl apply -k k3s_rencher
|
||||
```
|
||||
|
||||
The overlay currently installs the read-only agent account and its network
|
||||
policies. Add each workload namespace to its own Kustomize overlay and include
|
||||
`../../infrastructure/network-policies` in that overlay. NetworkPolicy is
|
||||
namespace-scoped, so a single policy cannot cover future namespaces.
|
||||
|
||||
## Network defaults
|
||||
|
||||
Managed namespaces start with deny-by-default ingress and egress. DNS is the
|
||||
only shared egress exception. Add explicit policies for application ingress,
|
||||
pod-to-pod traffic, and approved external destinations.
|
||||
|
||||
These policies do not restrict `hostNetwork` pods or traffic originating from a
|
||||
node. Avoid `hostNetwork` unless it is required and review workloads with node
|
||||
access separately.
|
||||
|
||||
## Agent access
|
||||
|
||||
The agent account uses Kubernetes' built-in `view` ClusterRole. It has no
|
||||
Secret permissions and no write, exec, attach, or port-forward permissions.
|
||||
Create a short-lived token at runtime:
|
||||
|
||||
```sh
|
||||
kubectl -n agent-gateway create token agent-readonly --duration=24h
|
||||
```
|
||||
|
||||
Do not commit the token, kubeconfig, K3s join token, or an unencrypted Secret.
|
||||
|
||||
## Cluster-specific settings
|
||||
|
||||
This repository currently manages one cluster, so its Kustomize entrypoint is
|
||||
at the root of `k3s_rencher/`. Keep shared policy in `infrastructure/` and add
|
||||
cluster-specific settings there as the installation grows.
|
||||
@@ -0,0 +1,7 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: agent-gateway
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- rbac.yaml
|
||||
- ../network-policies
|
||||
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: agent-gateway
|
||||
@@ -0,0 +1,18 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: agent-readonly
|
||||
namespace: agent-gateway
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: agent-readonly-view
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: view
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: agent-readonly
|
||||
namespace: agent-gateway
|
||||
@@ -0,0 +1,21 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: allow-cluster-dns
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Egress
|
||||
egress:
|
||||
- to:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: kube-system
|
||||
podSelector:
|
||||
matchLabels:
|
||||
k8s-app: kube-dns
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
@@ -0,0 +1,17 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny-ingress
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny-egress
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Egress
|
||||
@@ -0,0 +1,5 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- default-deny.yaml
|
||||
- allow-dns.yaml
|
||||
@@ -0,0 +1,4 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- infrastructure/agent-gateway
|
||||
Reference in New Issue
Block a user