Skip to content

Commit

Permalink
feat(t8s-cluster)!: change proxy to mirror (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwrau authored Sep 11, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 7e4af4e commit e405d74
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
{{- $_ := set . "Values" .context.Values -}}
{{- if .Values.containerRegistryProxy.proxyRegistryEndpoint }}
{{- if .Values.containerRegistryMirror.mirrorEndpoint }}
[plugins."io.containerd.grpc.v1.cri".registry]
config_path = "/etc/containerd/registries.conf.d"
{{- end }}
@@ -25,9 +25,9 @@
{{- end -}}
{{- end -}}

{{- define "t8s-cluster.clusterClass.containerdConfig.containerRegistryProxyConfigs" -}}
{{- define "t8s-cluster.clusterClass.containerdConfig.containerRegistryMirrorConfigs" -}}
{{- $_ := set . "Values" .context.Values -}}
{{- $defaultProxiedRegistries := list
{{- $defaultMirroredRegistries := list
"gcr.io"
"ghcr.io"
"k8s.gcr.io"
@@ -38,22 +38,22 @@
"registry.opensource.zalan.do"
"registry.teuto.io"
-}}
{{- $proxiedRegistries := concat $defaultProxiedRegistries (.Values.containerRegistryProxy.additionallyProxiedRegistries | default list) | sortAlpha | uniq -}}
{{- range $registry := $proxiedRegistries }}
{{- $mirroredRegistries := concat $defaultMirroredRegistries (.Values.containerRegistryMirror.additionallyMirroredRegistries | default list) | sortAlpha | uniq -}}
{{- range $registry := $mirroredRegistries }}
- content: |-
server = {{ printf "https://%s" $registry | quote }}
{{ printf `[host."%s"]` $.Values.containerRegistryProxy.proxyRegistryEndpoint }}
{{ printf `[host."%s"]` $.Values.containerRegistryMirror.mirrorEndpoint }}
capabilities = ["pull", "resolve"]
path: {{ printf `/etc/containerd/registries.conf.d/%s/hosts.toml` $registry }}
{{- end }}
- content: |-
server = "registry-1.docker.io"
{{ printf `[host."%s"]` $.Values.containerRegistryProxy.proxyRegistryEndpoint }}
{{ printf `[host."%s"]` $.Values.containerRegistryMirror.mirrorEndpoint }}
capabilities = ["pull", "resolve"]
path: /etc/containerd/registries.conf.d/docker.io/hosts.toml
- content: |- # this only works with containerd >=1.7.0, that's why the above still exists
server = "*"
{{ printf `[host."%s"]` $.Values.containerRegistryProxy.proxyRegistryEndpoint }}
{{ printf `[host."%s"]` $.Values.containerRegistryMirror.mirrorEndpoint }}
capabilities = ["pull", "resolve"]
path: /etc/containerd/registries.conf.d/_default/hosts.toml
{{- end -}}
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ joinConfiguration:
patches:
directory: /etc/kubernetes/patches
files: {{- include "t8s-cluster.patches.kubelet.patches" .context | nindent 2 }}
{{- if .Values.containerRegistryProxy.proxyRegistryEndpoint }}
{{- include "t8s-cluster.clusterClass.containerdConfig.containerRegistryProxyConfigs" (dict "context" .context) | nindent 2 }}
{{- if .Values.containerRegistryMirror.mirrorEndpoint }}
{{- include "t8s-cluster.clusterClass.containerdConfig.containerRegistryMirrorConfigs" (dict "context" .context) | nindent 2 }}
{{- end }}
- content: |- {{- include "t8s-cluster.clusterClass.containerdConfig.plugins" (dict "context" .context "gpu" .gpu) | nindent 6 }}
path: /etc/containerd/conf.d/plugins.toml
Original file line number Diff line number Diff line change
@@ -46,8 +46,8 @@ files: {{- include "t8s-cluster.patches.kubelet.patches" $ | nindent 2 }}
permissions: "0700"
- content: |- {{- .Files.Get "files/kube-proxy.config.yaml" | nindent 6 }}
path: /etc/kube-proxy-config.yaml
{{- if .Values.containerRegistryProxy.proxyRegistryEndpoint }}
{{- include "t8s-cluster.clusterClass.containerdConfig.containerRegistryProxyConfigs" (dict "context" $) | nindent 2 }}
{{- if .Values.containerRegistryMirror.mirrorEndpoint }}
{{- include "t8s-cluster.clusterClass.containerdConfig.containerRegistryMirrorConfigs" (dict "context" $) | nindent 2 }}
{{- end }}
- content: |- {{- include "t8s-cluster.clusterClass.containerdConfig.plugins" (dict "context" $ "gpu" false) | nindent 6 }}
path: /etc/containerd/conf.d/plugins.toml
6 changes: 3 additions & 3 deletions charts/t8s-cluster/values.schema.json
Original file line number Diff line number Diff line change
@@ -216,16 +216,16 @@
},
"additionalProperties": false
},
"containerRegistryProxy": {
"containerRegistryMirror": {
"type": "object",
"properties": {
"additionallyProxiedRegistries": {
"additionallyMirroredRegistries": {
"type": "array",
"items": {
"type": "string"
}
},
"proxyRegistryEndpoint": {
"mirrorEndpoint": {
"type": "string"
}
},
6 changes: 3 additions & 3 deletions charts/t8s-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -60,9 +60,9 @@ bastion:
availabilityZone: null
sshKeyName: null

containerRegistryProxy:
additionallyProxiedRegistries: []
proxyRegistryEndpoint: https://mirror.teuto.net
containerRegistryMirror:
additionallyMirroredRegistries: []
mirrorEndpoint: https://mirror.teuto.net

sshKeyName: null

0 comments on commit e405d74

Please sign in to comment.