Skip to content

Commit

Permalink
upgrade to kustomize 5.1.1 (#3996)
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig O'Donnell authored Aug 4, 2023
1 parent 704ef78 commit 009ff86
Show file tree
Hide file tree
Showing 45 changed files with 116 additions and 102 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/alpha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,6 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: '^1.20.0'

# GH Runners have kustomize 5.1.x installed, which is not _yet_ compatible with KOTS
- name: install kustomize 5.0.1
env:
KUSTOMIZE5_VERSION: 5.0.1
KUSTOMIZE5_SHA256SUM: dca623b36aef84fbdf28f79d02e9b3705ff641424ac1f872d5420dadb12fb78d
run: |
mkdir -p /tmp/kustomize \
&& pushd /tmp/kustomize
export KUSTOMIZE5_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE5_VERSION}/kustomize_v${KUSTOMIZE5_VERSION}_linux_amd64.tar.gz
curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& echo "${KUSTOMIZE5_SHA256SUM} kustomize.tar.gz" | sha256sum -c - \
&& tar -xzvf kustomize.tar.gz \
&& rm kustomize.tar.gz \
&& chmod a+x kustomize \
&& mv kustomize /usr/local/bin/kustomize
popd

- name: Checkout
uses: actions/checkout@v3
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,6 @@ jobs:
with:
go-version: '^1.20.0'
cache: true
# GH Runners have kustomize 5.1.x installed, which is not _yet_ compatible with KOTS
- name: install kustomize 5.0.1
env:
KUSTOMIZE5_VERSION: 5.0.1
KUSTOMIZE5_SHA256SUM: dca623b36aef84fbdf28f79d02e9b3705ff641424ac1f872d5420dadb12fb78d
run: |
mkdir -p /tmp/kustomize \
&& pushd /tmp/kustomize
export KUSTOMIZE5_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE5_VERSION}/kustomize_v${KUSTOMIZE5_VERSION}_linux_amd64.tar.gz
curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& echo "${KUSTOMIZE5_SHA256SUM} kustomize.tar.gz" | sha256sum -c - \
&& tar -xzvf kustomize.tar.gz \
&& rm kustomize.tar.gz \
&& chmod a+x kustomize \
&& mv kustomize /usr/local/bin/kustomize
popd

- name: test
run: make ci-test
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,6 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: '^1.20.0'
# GH Runners have kustomize 5.1.x installed, which is not _yet_ compatible with KOTS
- name: install kustomize 5.0.1
env:
KUSTOMIZE5_VERSION: 5.0.1
KUSTOMIZE5_SHA256SUM: dca623b36aef84fbdf28f79d02e9b3705ff641424ac1f872d5420dadb12fb78d
run: |
mkdir -p /tmp/kustomize \
&& pushd /tmp/kustomize
export KUSTOMIZE5_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE5_VERSION}/kustomize_v${KUSTOMIZE5_VERSION}_linux_amd64.tar.gz
curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& echo "${KUSTOMIZE5_SHA256SUM} kustomize.tar.gz" | sha256sum -c - \
&& tar -xzvf kustomize.tar.gz \
&& rm kustomize.tar.gz \
&& chmod a+x kustomize \
&& mv kustomize /usr/local/bin/kustomize
popd
- name: Checkout
uses: actions/checkout@v3
- name: Cache Go modules
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ report-metric:

.PHONY: test
test:
if [ -n $(RUN) ]; then \
if [ -n "$(RUN)" ]; then \
go test $(TEST_BUILDFLAGS) ./pkg/... ./cmd/... -coverprofile cover.out -run $(RUN); \
else \
go test $(TEST_BUILDFLAGS) ./pkg/... ./cmd/... -coverprofile cover.out; \
Expand Down
4 changes: 2 additions & 2 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ RUN curl -fsSLO "${KUBECTL_1_27_URL}" \
ENV KOTS_KUSTOMIZE_BIN_DIR=/usr/local/bin

# Install kustomize 5
ENV KUSTOMIZE5_VERSION=5.0.1
ENV KUSTOMIZE5_VERSION=5.1.1
ENV KUSTOMIZE5_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE5_VERSION}/kustomize_v${KUSTOMIZE5_VERSION}_linux_amd64.tar.gz
ENV KUSTOMIZE5_SHA256SUM=dca623b36aef84fbdf28f79d02e9b3705ff641424ac1f872d5420dadb12fb78d
ENV KUSTOMIZE5_SHA256SUM=3b30477a7ff4fb6547fa77d8117e66d995c2bdd526de0dafbf8b7bcb9556c85d
RUN curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& echo "${KUSTOMIZE5_SHA256SUM} kustomize.tar.gz" | sha256sum -c - \
&& tar -xzvf kustomize.tar.gz \
Expand Down
4 changes: 2 additions & 2 deletions deploy/okteto/okteto-v2.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ ENV KOTS_KUSTOMIZE_BIN_DIR=/usr/local/bin
# CURRENNTLY ONLY ONE VERSION IS SHIPPED BELOW

# Install kustomize 5
ENV KUSTOMIZE5_VERSION=5.0.1
ENV KUSTOMIZE5_VERSION=5.1.1
ENV KUSTOMIZE5_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE5_VERSION}/kustomize_v${KUSTOMIZE5_VERSION}_linux_amd64.tar.gz
ENV KUSTOMIZE5_SHA256SUM=dca623b36aef84fbdf28f79d02e9b3705ff641424ac1f872d5420dadb12fb78d
ENV KUSTOMIZE5_SHA256SUM=3b30477a7ff4fb6547fa77d8117e66d995c2bdd526de0dafbf8b7bcb9556c85d
RUN curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& echo "${KUSTOMIZE5_SHA256SUM} kustomize.tar.gz" | sha256sum -c - \
&& tar -xzvf kustomize.tar.gz \
Expand Down
4 changes: 2 additions & 2 deletions deploy/okteto/okteto.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ ENV KOTS_KUSTOMIZE_BIN_DIR=/usr/local/bin
# CURRENNTLY ONLY ONE VERSION IS SHIPPED BELOW

# Install kustomize 5
ENV KUSTOMIZE5_VERSION=5.0.1
ENV KUSTOMIZE5_VERSION=5.1.1
ENV KUSTOMIZE5_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE5_VERSION}/kustomize_v${KUSTOMIZE5_VERSION}_linux_amd64.tar.gz
ENV KUSTOMIZE5_SHA256SUM=dca623b36aef84fbdf28f79d02e9b3705ff641424ac1f872d5420dadb12fb78d
ENV KUSTOMIZE5_SHA256SUM=3b30477a7ff4fb6547fa77d8117e66d995c2bdd526de0dafbf8b7bcb9556c85d
RUN curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& echo "${KUSTOMIZE5_SHA256SUM} kustomize.tar.gz" | sha256sum -c - \
&& tar -xzvf kustomize.tar.gz \
Expand Down
4 changes: 2 additions & 2 deletions hack/dev/skaffold.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ ENV KOTS_KUSTOMIZE_BIN_DIR=/usr/local/bin
# CURRENNTLY ONLY ONE VERSION IS SHIPPED BELOW

# Install kustomize 5
ENV KUSTOMIZE5_VERSION=5.0.1
ENV KUSTOMIZE5_VERSION=5.1.1
ENV KUSTOMIZE5_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE5_VERSION}/kustomize_v${KUSTOMIZE5_VERSION}_linux_amd64.tar.gz
ENV KUSTOMIZE5_SHA256SUM=dca623b36aef84fbdf28f79d02e9b3705ff641424ac1f872d5420dadb12fb78d
ENV KUSTOMIZE5_SHA256SUM=3b30477a7ff4fb6547fa77d8117e66d995c2bdd526de0dafbf8b7bcb9556c85d
RUN curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& echo "${KUSTOMIZE5_SHA256SUM} kustomize.tar.gz" | sha256sum -c - \
&& tar -xzvf kustomize.tar.gz \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- manifests/cron-deployment.yaml
- manifests/postgres-service.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- manifests/cron-deployment.yaml
- manifests/postgres-service.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- manifests/cron-deployment.yaml
- manifests/postgres-service.yaml
Expand Down
5 changes: 5 additions & 0 deletions pkg/base/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ func (b *Base) writeBase(options WriteOptions, isTopLevelBase bool) ([]string, [
APIVersion: "kustomize.config.k8s.io/v1beta1",
Kind: "Kustomization",
},
MetaData: &kustomizetypes.ObjectMeta{
Annotations: map[string]string{
"kots.io/kustomization": "base",
},
},
Namespace: b.Namespace,
Resources: kustomizeResources,
PatchesStrategicMerge: kustomizePatches,
Expand Down
22 changes: 0 additions & 22 deletions pkg/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
k8sjson "k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/client-go/kubernetes/scheme"
kustomizetypes "sigs.k8s.io/kustomize/api/types"
)

type PullOptions struct {
Expand Down Expand Up @@ -721,27 +720,6 @@ func writeDownstreams(options PullOptions, overlaysDir string, m *midstream.Mids
return nil
}

func writeCombinedDownstreamBase(downstreamName string, bases []string, renderDir string) error {
if _, err := os.Stat(renderDir); os.IsNotExist(err) {
if err := os.MkdirAll(renderDir, 0744); err != nil {
return errors.Wrap(err, "failed to mkdir")
}
}

kustomization := kustomizetypes.Kustomization{
TypeMeta: kustomizetypes.TypeMeta{
APIVersion: "kustomize.config.k8s.io/v1beta1",
Kind: "Kustomization",
},
Bases: bases,
}
if err := k8sutil.WriteKustomizationToFile(kustomization, filepath.Join(renderDir, "kustomization.yaml")); err != nil {
return errors.Wrap(err, "failed to write kustomization to file")
}

return nil
}

func ParseConfigValuesFromFile(filename string) (*kotsv1beta1.ConfigValues, error) {
contents, err := ioutil.ReadFile(filename)
if err != nil {
Expand Down
22 changes: 0 additions & 22 deletions pkg/rewrite/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/replicatedhq/kots/pkg/upstream"
upstreamtypes "github.com/replicatedhq/kots/pkg/upstream/types"
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
kustomizetypes "sigs.k8s.io/kustomize/api/types"
)

type RewriteOptions struct {
Expand Down Expand Up @@ -404,24 +403,3 @@ func writeDownstreams(options RewriteOptions, overlaysDir string, m *midstream.M

return nil
}

func writeCombinedDownstreamBase(downstreamName string, bases []string, renderDir string) error {
if _, err := os.Stat(renderDir); os.IsNotExist(err) {
if err := os.MkdirAll(renderDir, 0744); err != nil {
return errors.Wrap(err, "failed to mkdir")
}
}

kustomization := kustomizetypes.Kustomization{
TypeMeta: kustomizetypes.TypeMeta{
APIVersion: "kustomize.config.k8s.io/v1beta1",
Kind: "Kustomization",
},
Bases: bases,
}
if err := k8sutil.WriteKustomizationToFile(kustomization, filepath.Join(renderDir, "kustomization.yaml")); err != nil {
return errors.Wrap(err, "failed to write kustomization to file")
}

return nil
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- chartHelmSecret.yaml
- test-1.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/test-1.yaml
- templates/test-2.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- charts/test-chart-2/chartHelmSecret.yaml
- charts/test-chart-2/test-1.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- pod.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- subdir/configmap.yaml
- subdir/secrets-2.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/test-1.yaml
- templates/test-2.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/test-1.yaml
- templates/test-2.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/test-1.yaml
- templates/test-2.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- subdir/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/deployment.yaml
- templates/service.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/deployment.yaml
- templates/service.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/deployment.yaml
- templates/service.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/deployment.yaml
- templates/service.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/deployment.yaml
- templates/service.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- subdir/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/my-subsubsubchart-pod.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- templates/my-subsubchart-pod.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
annotations:
kots.io/kustomization: base
resources:
- my-subchart-crd.yaml
Loading

0 comments on commit 009ff86

Please sign in to comment.