Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k8s: update base svc pkg to avoid merge bug downstream #108

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions k8s/base/svc-frontend/Kptfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ upstream:
repo: https://github.com/LCOGT/kpt-pkg-catalog
directory: /service
ref: main
updateStrategy: resource-merge
updateStrategy: force-delete-replace
upstreamLock:
type: git
git:
repo: https://github.com/LCOGT/kpt-pkg-catalog
directory: /service
ref: main
commit: ddad41bfb8f928aa4367d86e7da6677200fe4f26
commit: c58213d7a52130c977fdff0a51f4bd4fb5ca73a3
pipeline:
mutators:
- image: gcr.io/kpt-fn/apply-replacements:v0.1.1
Expand Down
4 changes: 2 additions & 2 deletions k8s/base/svc-frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Description

This package provides a bare-bones `v1.Service` that you can build upon
and use in other packages.
This package provides a bare-bones [`v1.Service`](https://kubernetes.io/docs/concepts/services-networking/service/)
that you can build upon and use in other packages.

## Usage

Expand Down
24 changes: 3 additions & 21 deletions k8s/base/svc-frontend/fn-replacements.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
apiVersion: fn.kpt.dev/v1alpha1
kind: ApplyReplacements
metadata: # kpt-merge: /svc-example
name: svc-frontend
metadata: # kpt-merge: /svc
name: svc
annotations:
config.kubernetes.io/local-config: "true"
internal.kpt.dev/upstream-identifier: 'fn.kpt.dev|ApplyReplacements|default|svc-example'
internal.kpt.dev/upstream-identifier: 'fn.kpt.dev|ApplyReplacements|default|svc'
replacements:
- source:
kind: Service
fieldPath: metadata.name
targets:
- select:
kind: Kustomization
fieldPaths:
- metadata.name
options:
delimiter: "svc-"
index: 1
- select:
kind: ApplyReplacements
fieldPaths:
- metadata.name
options:
delimiter: "svc-"
index: 1
- source:
kind: Service
fieldPath: spec.selector.[app.kubernetes.io/component]
Expand Down
14 changes: 5 additions & 9 deletions k8s/base/svc-frontend/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata: # kpt-merge: /svc-example
name: svc-frontend
metadata: # kpt-merge: /svc
name: svc
annotations:
config.kubernetes.io/local-config: "true"
internal.kpt.dev/upstream-identifier: 'kustomize.config.k8s.io|Kustomization|default|svc-example'
internal.kpt.dev/upstream-identifier: 'kustomize.config.k8s.io|Kustomization|default|svc'
resources:
- ./svc.yaml
patches:
- target:
annotationSelector: internal.kpt.dev/upstream-identifier
patch: |-
- op: remove
path: /metadata/annotations/internal.kpt.dev~1upstream-identifier
components:
- ./remove-kpt-internal-annotations/
20 changes: 20 additions & 0 deletions k8s/base/svc-frontend/remove-kpt-internal-annotations/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: remove-kpt-internal-annotations
annotations:
config.kubernetes.io/local-config: "true"
upstream:
type: git
git:
repo: https://github.com/LCOGT/kpt-pkg-catalog
directory: /remove-kpt-internal-annotations
ref: main
updateStrategy: resource-merge
upstreamLock:
type: git
git:
repo: https://github.com/LCOGT/kpt-pkg-catalog
directory: /remove-kpt-internal-annotations
ref: main
commit: c58213d7a52130c977fdff0a51f4bd4fb5ca73a3
25 changes: 25 additions & 0 deletions k8s/base/svc-frontend/remove-kpt-internal-annotations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# remove-kpt-internal-annotations

## Description

This package provides a [Kustomize `Component`](https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/1802-kustomize-components)
that can be used to remove `internal.kpt.dev/upstream-identifier` annotations from all rendered KRM objects.

## Usage

Clone this package:

```shell
kpt pkg get https://github.com/LCOGT/kpt-pkg-catalog/remove-kpt-internal-annotations
```

And then reference it from another Kustomization:


```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

components:
- ./remove-kpt-internal-annotations/
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
metadata: # kpt-merge: /remove-kpt-internal-annotations
name: remove-kpt-internal-annotations
annotations:
config.kubernetes.io/local-config: "true"
internal.kpt.dev/upstream-identifier: 'kustomize.config.k8s.io|Component|default|remove-kpt-internal-annotations'
patches:
- target:
annotationSelector: internal.kpt.dev/upstream-identifier
patch: |-
- op: remove
path: /metadata/annotations/internal.kpt.dev~1upstream-identifier
6 changes: 3 additions & 3 deletions k8s/base/svc-frontend/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ apiVersion: v1
kind: Service
metadata: # kpt-merge: /example
name: frontend
annotations:
internal.kpt.dev/upstream-identifier: '|Service|default|frontend'
labels:
app.kubernetes.io/component: frontend
annotations:
internal.kpt.dev/upstream-identifier: '|Service|default|example'
spec:
type: ClusterIP
selector:
app.kubernetes.io/component: frontend
ports:
- name: frontend
port: 8080
targetPort: frontend
targetPort: "frontend"
Loading