mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
kustomize: Add support for OCI based helm repos (#5167)
* kustomize: Add support for OCI based helm repos Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de> * Update api/internal/builtins/HelmChartInflationGenerator.go * Update plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go * go fmt Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de> * s/expectedHelmExternalDns/expectedHelmExternalDNS Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de> * commit Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de> * commit with content Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de> * Apply suggestions from maintainer * go work sync * added test --------- Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
This commit is contained in:
@@ -31,7 +31,7 @@ require (
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/xlab/treeprint v1.2.0 // indirect
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -62,8 +62,7 @@ github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
|
||||
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
|
||||
@@ -281,8 +281,18 @@ func (p *HelmChartInflationGeneratorPlugin) pullCommand() []string {
|
||||
"pull",
|
||||
"--untar",
|
||||
"--untardir", p.absChartHome(),
|
||||
"--repo", p.Repo,
|
||||
p.Name}
|
||||
}
|
||||
|
||||
switch {
|
||||
case strings.HasPrefix(p.Repo, "oci://"):
|
||||
args = append(args, strings.TrimSuffix(p.Repo, "/")+"/"+p.Name)
|
||||
case p.Repo != "":
|
||||
args = append(args, "--repo", p.Repo)
|
||||
fallthrough
|
||||
default:
|
||||
args = append(args, p.Name)
|
||||
}
|
||||
|
||||
if p.Version != "" {
|
||||
args = append(args, "--version", p.Version)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
"sigs.k8s.io/kustomize/kyaml/copyutil"
|
||||
)
|
||||
|
||||
const expectedHelm = `
|
||||
const (
|
||||
expectedHelm = `
|
||||
apiVersion: v1
|
||||
data:
|
||||
rcon-password: Q0hBTkdFTUUh
|
||||
@@ -46,6 +47,98 @@ spec:
|
||||
type: ClusterIP
|
||||
`
|
||||
|
||||
expectedHelmExternalDNS = `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/instance: test
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: external-dns
|
||||
helm.sh/chart: external-dns-6.19.2
|
||||
name: test-external-dns
|
||||
namespace: default
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/instance: test
|
||||
app.kubernetes.io/name: external-dns
|
||||
template:
|
||||
metadata:
|
||||
annotations: null
|
||||
labels:
|
||||
app.kubernetes.io/instance: test
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: external-dns
|
||||
helm.sh/chart: external-dns-6.19.2
|
||||
spec:
|
||||
affinity:
|
||||
nodeAffinity: null
|
||||
podAffinity: null
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- podAffinityTerm:
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/instance: test
|
||||
app.kubernetes.io/name: external-dns
|
||||
topologyKey: kubernetes.io/hostname
|
||||
weight: 1
|
||||
containers:
|
||||
- args:
|
||||
- --metrics-address=:7979
|
||||
- --log-level=info
|
||||
- --log-format=text
|
||||
- --policy=upsert-only
|
||||
- --provider=aws
|
||||
- --registry=txt
|
||||
- --interval=1m
|
||||
- --source=service
|
||||
- --source=ingress
|
||||
- --aws-api-retries=3
|
||||
- --aws-zone-type=
|
||||
- --aws-batch-change-size=1000
|
||||
env:
|
||||
- name: AWS_DEFAULT_REGION
|
||||
value: us-east-1
|
||||
envFrom: null
|
||||
image: docker.io/bitnami/external-dns:0.13.4-debian-11-r14
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
failureThreshold: 2
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
name: external-dns
|
||||
ports:
|
||||
- containerPort: 7979
|
||||
name: http
|
||||
readinessProbe:
|
||||
failureThreshold: 6
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
resources:
|
||||
limits: {}
|
||||
requests: {}
|
||||
volumeMounts: null
|
||||
securityContext:
|
||||
fsGroup: 1001
|
||||
runAsUser: 1001
|
||||
serviceAccountName: default
|
||||
volumes: null
|
||||
`
|
||||
)
|
||||
|
||||
func TestHelmChartInflationGeneratorOld(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
|
||||
defer th.Reset()
|
||||
@@ -84,6 +177,64 @@ helmCharts:
|
||||
th.AssertActualEqualsExpected(m, expectedHelm)
|
||||
}
|
||||
|
||||
func TestHelmChartInflationGeneratorWithOciRepository(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
|
||||
defer th.Reset()
|
||||
if err := th.ErrIfNoHelm(); err != nil {
|
||||
t.Skip("skipping: " + err.Error())
|
||||
}
|
||||
|
||||
th.WriteK(th.GetRoot(), `
|
||||
helmCharts:
|
||||
- name: external-dns
|
||||
repo: oci://registry-1.docker.io/bitnamicharts
|
||||
version: 6.19.2
|
||||
releaseName: test
|
||||
valuesInline:
|
||||
crd:
|
||||
create: false
|
||||
rbac:
|
||||
create: false
|
||||
serviceAccount:
|
||||
create: false
|
||||
service:
|
||||
enabled: false
|
||||
|
||||
`)
|
||||
|
||||
m := th.Run(th.GetRoot(), th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, expectedHelmExternalDNS)
|
||||
}
|
||||
|
||||
func TestHelmChartInflationGeneratorWithOciRepositoryWithAppendSlash(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
|
||||
defer th.Reset()
|
||||
if err := th.ErrIfNoHelm(); err != nil {
|
||||
t.Skip("skipping: " + err.Error())
|
||||
}
|
||||
|
||||
th.WriteK(th.GetRoot(), `
|
||||
helmCharts:
|
||||
- name: external-dns
|
||||
repo: oci://registry-1.docker.io/bitnamicharts/
|
||||
version: 6.19.2
|
||||
releaseName: test
|
||||
valuesInline:
|
||||
crd:
|
||||
create: false
|
||||
rbac:
|
||||
create: false
|
||||
serviceAccount:
|
||||
create: false
|
||||
service:
|
||||
enabled: false
|
||||
|
||||
`)
|
||||
|
||||
m := th.Run(th.GetRoot(), th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, expectedHelmExternalDNS)
|
||||
}
|
||||
|
||||
// Last mile helm - show how kustomize puts helm charts into different
|
||||
// namespaces with different customizations.
|
||||
func TestHelmChartProdVsDev(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user