Securing k3s deployment
This commit is contained in:
parent
3fd4c7dee0
commit
5717cca04d
7 changed files with 153 additions and 6 deletions
|
|
@ -1,5 +1,18 @@
|
|||
flannel-backend: wireguard-native
|
||||
protect-kernel-defaults: true
|
||||
{% if kubernetes_master|bool %}
|
||||
secrets-encryption: true
|
||||
kube-apiserver-arg:
|
||||
- "enable-admission-plugins=NodeRestriction,AlwaysPullImages,EventRateLimit"
|
||||
- 'admission-control-config-file=/etc/kubernetes/psa.yaml'
|
||||
- 'audit-log-path=/var/log/apiserver/audit.log'
|
||||
- 'audit-policy-file=/etc/kubernetes/policies/audit-policy.yaml'
|
||||
- 'audit-log-maxage=30'
|
||||
- 'audit-log-maxbackup=10'
|
||||
- 'audit-log-maxsize=100'
|
||||
# - "request-timeout=300s"
|
||||
kube-controller-manager-arg:
|
||||
- 'terminated-pod-gc-threshold=10'
|
||||
{% if vars['KubernetesMasterConfigured_' ~ kubernetes_cluster_name] is not defined %}
|
||||
cluster-init: true
|
||||
{% else %}
|
||||
|
|
@ -10,15 +23,18 @@ token: ${NODE_TOKEN}
|
|||
server: https://{{ kubernetes_master }}:6443
|
||||
token: ${NODE_TOKEN}
|
||||
{% endif %}
|
||||
#node-label:
|
||||
# - "foo=bar"
|
||||
# - "something=amazing"
|
||||
kubelet-arg:
|
||||
- 'streaming-connection-idle-timeout=5m'
|
||||
- "tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
|
||||
{% if ansible_os_family == "RedHat" %}
|
||||
selinux: true
|
||||
{% endif %}
|
||||
secrets-encryption: true
|
||||
#embedded-registry: true
|
||||
disable:
|
||||
- traefik
|
||||
{% if false %}
|
||||
# node-external-ip: 1.2.3.4
|
||||
#node-label:
|
||||
# - "foo=bar"
|
||||
# - "something=amazing"
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ controlPlaneEndpoint: "{{ lookup('vars', 'ansible_' + kubernetes_interface ).ipv
|
|||
{% endif %}
|
||||
apiServer:
|
||||
extraArgs:
|
||||
enable-admission-plugins: NodeRestriction
|
||||
enable-admission-plugins: NodeRestriction,AlwaysPullImages,EventRateLimit
|
||||
authorization-mode: "Node,RBAC"
|
||||
audit-policy-file: "/etc/kubernetes/policies/audit-policy.yaml"
|
||||
audit-log-path: "/var/log/apiserver/audit.log"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
kind: NetworkPolicy
|
||||
apiVersion: networking.k8s.io/v1
|
||||
metadata:
|
||||
name: intra-namespace
|
||||
namespace: kube-system
|
||||
spec:
|
||||
podSelector: {}
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
name: kube-system
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-network-dns-policy
|
||||
namespace: <NAMESPACE>
|
||||
spec:
|
||||
ingress:
|
||||
- ports:
|
||||
- port: 53
|
||||
protocol: TCP
|
||||
- port: 53
|
||||
protocol: UDP
|
||||
podSelector:
|
||||
matchLabels:
|
||||
k8s-app: kube-dns
|
||||
policyTypes:
|
||||
- Ingress
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: allow-all-metrics-server
|
||||
namespace: kube-system
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
k8s-app: metrics-server
|
||||
ingress:
|
||||
- {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: allow-all-svclbtraefik-ingress
|
||||
namespace: kube-system
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
svccontroller.k3s.cattle.io/svcname: traefik
|
||||
ingress:
|
||||
- {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: allow-all-traefik-v121-ingress
|
||||
namespace: kube-system
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: traefik
|
||||
ingress:
|
||||
- {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
---
|
||||
Loading…
Add table
Add a link
Reference in a new issue