Skip to content

Commit

Permalink
Add pod disruption budgets so the cluster-autoscaler is able to move …
Browse files Browse the repository at this point in the history
…kube-admin namespaced resources (#2781)

* helm: refactor cilium helm values

* helm: add pod disruption budgets
  • Loading branch information
3u13r authored Jan 3, 2024
1 parent 0167a4a commit 15cc7b9
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 263 deletions.
1 change: 1 addition & 0 deletions internal/constellation/helm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ go_library(
"charts/cert-manager/templates/controller-config.yaml",
"charts/cert-manager/templates/poddisruptionbudget.yaml",
"charts/cert-manager/templates/webhook-poddisruptionbudget.yaml",
"charts/edgeless/constellation-services/charts/autoscaler/templates/coredns-pdb.yaml",
],
importpath = "github.com/edgelesssys/constellation/v2/internal/constellation/helm",
visibility = ["//:__subpackages__"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coredns-pdb
namespace: "kube-system"
spec:
maxUnavailable: 1
selector:
matchLabels:
k8s-app: kube-dns
102 changes: 98 additions & 4 deletions internal/constellation/helm/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,9 @@ func (i *chartLoader) loadRelease(info chartInfo, helmWaitMode WaitMode) (releas

switch info.releaseName {
case ciliumInfo.releaseName:
var ok bool
values, ok = ciliumVals[i.csp.String()]
if !ok {
return release{}, fmt.Errorf("cilium values for csp %q not found", i.csp.String())
values, err = i.loadCiliumValues(i.csp)
if err != nil {
return release{}, fmt.Errorf("loading cilium values: %w", err)
}
case certManagerInfo.releaseName:
values = i.loadCertManagerValues()
Expand Down Expand Up @@ -230,9 +229,17 @@ func (i *chartLoader) loadCertManagerValues() map[string]any {
"tolerations": controlPlaneTolerations,
"webhook": map[string]any{
"tolerations": controlPlaneTolerations,
"podDisruptionBudget": map[string]any{
"enabled": true,
},
"replicaCount": 2,
},
"cainjector": map[string]any{
"tolerations": controlPlaneTolerations,
"podDisruptionBudget": map[string]any{
"enabled": true,
},
"replicaCount": 2,
},
"startupapicheck": map[string]any{
"timeout": "5m",
Expand All @@ -241,6 +248,10 @@ func (i *chartLoader) loadCertManagerValues() map[string]any {
},
"tolerations": controlPlaneTolerations,
},
"podDisruptionBudget": map[string]any{
"enabled": true,
},
"replicaCount": 2,
}
}

Expand Down Expand Up @@ -321,6 +332,89 @@ func (i *chartLoader) cspTags() map[string]any {
}
}

func (i *chartLoader) loadCiliumValues(cloudprovider.Provider) (map[string]any, error) {
sharedConfig := map[string]any{
"extraArgs": []string{"--node-encryption-opt-out-labels=invalid.label"},
"endpointRoutes": map[string]any{
"enabled": true,
},
"l7Proxy": false,
"image": map[string]any{
"repository": "ghcr.io/3u13r/cilium",
"suffix": "",
"tag": "v1.15.0-pre.2-edg.1",
"digest": "sha256:eebf631fd0f27e1f28f1fdeb2e049f2c83b887381466245c4b3e26440daefa27",
"useDigest": true,
},
"operator": map[string]any{
"image": map[string]any{
"repository": "ghcr.io/3u13r/operator",
"tag": "v1.15.0-pre.2-edg.1",
"suffix": "",
"genericDigest": "sha256:bfaeac2e05e8c38f439b0fbc36558fd8d11602997f2641423e8d86bd7ac6a88c",
"useDigest": true,
},
"podDisruptionBudget": map[string]any{
"enabled": true,
},
},
"encryption": map[string]any{
"enabled": true,
"type": "wireguard",
"nodeEncryption": true,
"strictMode": map[string]any{
"enabled": true,
"podCIDRList": []string{"10.244.0.0/16"},
"allowRemoteNodeIdentities": false,
},
},
"ipam": map[string]any{
"operator": map[string]any{
"clusterPoolIPv4PodCIDRList": []string{
"10.244.0.0/16",
},
},
},
"bpf": map[string]any{
"masquerade": true,
},
"ipMasqAgent": map[string]any{
"enabled": true,
"config": map[string]any{
"masqLinkLocal": true,
},
},
"kubeProxyReplacement": "strict",
"enableCiliumEndpointSlice": true,
"kubeProxyReplacementHealthzBindAddr": "0.0.0.0:10256",
}
cspOverrideConfigs := map[string]map[string]any{
cloudprovider.AWS.String(): {},
cloudprovider.Azure.String(): {},
cloudprovider.GCP.String(): {
"tunnel": "disabled",
"encryption": map[string]any{
"strictMode": map[string]any{
"podCIDRList": []string{""},
},
},
"ipam": map[string]any{
"mode": "kubernetes",
},
},
cloudprovider.OpenStack.String(): {},
cloudprovider.QEMU.String(): {
"extraArgs": []string{""},
},
}

cspValues, ok := cspOverrideConfigs[i.csp.String()]
if !ok {
return nil, fmt.Errorf("cilium values for csp %q not found", i.csp.String())
}
return mergeMaps(sharedConfig, cspValues), nil
}

// updateVersions changes all versions of direct dependencies that are set to "0.0.0" to newVersion.
func updateVersions(chart *chart.Chart, newVersion semver.Semver) {
chart.Metadata.Version = newVersion.String()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coredns-pdb
namespace: kube-system
spec:
maxUnavailable: 1
selector:
matchLabels:
k8s-app: kube-dns
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coredns-pdb
namespace: kube-system
spec:
maxUnavailable: 1
selector:
matchLabels:
k8s-app: kube-dns
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coredns-pdb
namespace: kube-system
spec:
maxUnavailable: 1
selector:
matchLabels:
k8s-app: kube-dns
Loading

0 comments on commit 15cc7b9

Please sign in to comment.