Skip to content

Commit

Permalink
🌱 : fix sample project-v4-grafana (kubernetes-sigs#3279)
Browse files Browse the repository at this point in the history
🐛 fix sample project-v4-grafana
  • Loading branch information
camilamacedo86 authored and Sajiyah-Salat committed Jun 11, 2023
1 parent b8f6d40 commit a3823a4
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 45 deletions.
12 changes: 6 additions & 6 deletions test/testdata/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ build_kb
scaffold_test_project project-v2 --project-version=2

# [Currently, default CLI plugin] - Project version 3 (default) uses plugin go/v3 (default).
scaffold_test_project project-v3
scaffold_test_project project-v3-multigroup
scaffold_test_project project-v3 --plugins="go/v3"
scaffold_test_project project-v3-multigroup --plugins="go/v3"
scaffold_test_project project-v3-declarative-v1 --plugins="go/v3,declarative"
scaffold_test_project project-v3-config --component-config
scaffold_test_project project-v3-with-deploy-image
scaffold_test_project project-v3-with-grafana
scaffold_test_project project-v3-config --component-config --plugins="go/v3"
scaffold_test_project project-v3-with-deploy-image --plugins="go/v3"
scaffold_test_project project-v3-with-grafana --plugins="go/v3"

# [Next version, alpha] Project version v4-alpha
scaffold_test_project project-v4 --plugins="go/v4"
scaffold_test_project project-v4-multigroup --plugins="go/v4"
scaffold_test_project project-v4-declarative-v1 --plugins="go/v4,declarative"
scaffold_test_project project-v4-config --component-config --plugins="go/v4"
scaffold_test_project project-v4-with-deploy-image --plugins="go/v4"
scaffold_test_project project-v4-with-grafana
scaffold_test_project project-v4-with-grafana --plugins="go/v4"
6 changes: 3 additions & 3 deletions testdata/project-v4-with-grafana/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/controller/ internal/controller/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
6 changes: 3 additions & 3 deletions testdata/project-v4-with-grafana/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ test: manifests generate fmt vet envtest ## Run tests.

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
go build -o bin/manager cmd/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
go run ./cmd/main.go

# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
Expand Down Expand Up @@ -132,7 +132,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
KUSTOMIZE_VERSION ?= v5.0.0
CONTROLLER_TOOLS_VERSION ?= v0.11.3

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-with-grafana/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: testproject.org
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
plugins:
grafana.kubebuilder.io/v1-alpha: {}
projectName: project-v4-with-grafana
Expand Down
File renamed without changes.
134 changes: 103 additions & 31 deletions testdata/project-v4-with-grafana/config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ namespace: project-v4-with-grafana-system
namePrefix: project-v4-with-grafana-

# Labels to add to all resources and selectors.
#commonLabels:
# someName: someValue
#labels:
#- includeSelectors: true
# pairs:
# someName: someValue

bases:
resources:
- ../crd
- ../rbac
- ../manager
Expand Down Expand Up @@ -41,32 +43,102 @@ patchesStrategicMerge:
# 'CERTMANAGER' needs to be enabled to use ca injection
#- webhookcainjection_patch.yaml

# the following config is for teaching kustomize how to do var substitution
vars:
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
# objref:
# kind: Certificate
# group: cert-manager.io
# version: v1
# name: serving-cert # this name should match the one in certificate.yaml
# fieldref:
# fieldpath: metadata.namespace
#- name: CERTIFICATE_NAME
# objref:
# kind: Certificate
# group: cert-manager.io
# version: v1
# name: serving-cert # this name should match the one in certificate.yaml
#- name: SERVICE_NAMESPACE # namespace of the service
# objref:
# kind: Service
# version: v1
# name: webhook-service
# fieldref:
# fieldpath: metadata.namespace
#- name: SERVICE_NAME
# objref:
# kind: Service
# version: v1
# name: webhook-service
# Uncomment the following replacements to add the cert-manager CA injection annotations
#replacements:
# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
# kind: Certificate
# group: cert-manager.io
# version: v1
# name: serving-cert # this name should match the one in certificate.yaml
# fieldPath: .metadata.namespace # namespace of the certificate CR
# targets:
# - select:
# kind: ValidatingWebhookConfiguration
# fieldPaths:
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
# options:
# delimiter: '/'
# index: 0
# create: true
# - select:
# kind: MutatingWebhookConfiguration
# fieldPaths:
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
# options:
# delimiter: '/'
# index: 0
# create: true
# - select:
# kind: CustomResourceDefinition
# fieldPaths:
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
# options:
# delimiter: '/'
# index: 0
# create: true
# - source:
# kind: Certificate
# group: cert-manager.io
# version: v1
# name: serving-cert # this name should match the one in certificate.yaml
# fieldPath: .metadata.name
# targets:
# - select:
# kind: ValidatingWebhookConfiguration
# fieldPaths:
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
# options:
# delimiter: '/'
# index: 1
# create: true
# - select:
# kind: MutatingWebhookConfiguration
# fieldPaths:
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
# options:
# delimiter: '/'
# index: 1
# create: true
# - select:
# kind: CustomResourceDefinition
# fieldPaths:
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
# options:
# delimiter: '/'
# index: 1
# create: true
# - source: # Add cert-manager annotation to the webhook Service
# kind: Service
# version: v1
# name: webhook-service
# fieldPath: .metadata.name # namespace of the service
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# fieldPaths:
# - .spec.dnsNames.0
# - .spec.dnsNames.1
# options:
# delimiter: '.'
# index: 0
# create: true
# - source:
# kind: Service
# version: v1
# name: webhook-service
# fieldPath: .metadata.namespace # namespace of the service
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# fieldPaths:
# - .spec.dnsNames.0
# - .spec.dnsNames.1
# options:
# delimiter: '.'
# index: 1
# create: true
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: serviceaccount
app.kubernetes.io/instance: controller-manager
app.kubernetes.io/instance: controller-manager-sa
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: project-v4-with-grafana
app.kubernetes.io/part-of: project-v4-with-grafana
Expand Down

0 comments on commit a3823a4

Please sign in to comment.