Skip to content

Commit 0694458

Browse files
committed
Add initial operator bootstrap files created by operator-sdk v1.15.0
1 parent f1803a9 commit 0694458

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3420
-1
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin
9+
10+
# editor and IDE paraphernalia
11+
.idea
12+
*.swp
13+
*.swo
14+
*~

Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Build the manager binary
2+
FROM quay.io/operator-framework/helm-operator:v1.15.0
3+
4+
ENV HOME=/opt/helm
5+
COPY watches.yaml ${HOME}/watches.yaml
6+
COPY helm-charts ${HOME}/helm-charts
7+
WORKDIR ${HOME}

Makefile

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# VERSION defines the project version for the bundle.
2+
# Update this value when you upgrade the version of your project.
3+
# To re-generate a bundle for another specific version without changing the standard setup, you can:
4+
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
5+
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6+
VERSION ?= 0.0.1
7+
8+
# CHANNELS define the bundle channels used in the bundle.
9+
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
10+
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
11+
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
12+
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
13+
ifneq ($(origin CHANNELS), undefined)
14+
BUNDLE_CHANNELS := --channels=$(CHANNELS)
15+
endif
16+
17+
# DEFAULT_CHANNEL defines the default channel used in the bundle.
18+
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
19+
# To re-generate a bundle for any other default channel without changing the default setup, you can:
20+
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
21+
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
22+
ifneq ($(origin DEFAULT_CHANNEL), undefined)
23+
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
24+
endif
25+
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
26+
27+
# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
28+
# This variable is used to construct full image tags for bundle and catalog images.
29+
#
30+
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
31+
# external-secrets.io/external-secrets-operator-bundle:$VERSION and external-secrets.io/external-secrets-operator-catalog:$VERSION.
32+
IMAGE_TAG_BASE ?= external-secrets.io/external-secrets-operator
33+
34+
# BUNDLE_IMG defines the image:tag used for the bundle.
35+
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
36+
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
37+
38+
# Image URL to use all building/pushing image targets
39+
IMG ?= controller:latest
40+
41+
all: docker-build
42+
43+
##@ General
44+
45+
# The help target prints out all targets with their descriptions organized
46+
# beneath their categories. The categories are represented by '##@' and the
47+
# target descriptions by '##'. The awk commands is responsible for reading the
48+
# entire set of makefiles included in this invocation, looking for lines of the
49+
# file as xyz: ## something, and then pretty-format the target and help. Then,
50+
# if there's a line with ##@ something, that gets pretty-printed as a category.
51+
# More info on the usage of ANSI control characters for terminal formatting:
52+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
53+
# More info on the awk command:
54+
# http://linuxcommand.org/lc3_adv_awk.php
55+
56+
help: ## Display this help.
57+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
58+
59+
##@ Build
60+
61+
run: helm-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
62+
$(HELM_OPERATOR) run
63+
64+
docker-build: ## Build docker image with the manager.
65+
docker build -t ${IMG} .
66+
67+
docker-push: ## Push docker image with the manager.
68+
docker push ${IMG}
69+
70+
##@ Deployment
71+
72+
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
73+
$(KUSTOMIZE) build config/crd | kubectl apply -f -
74+
75+
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
76+
$(KUSTOMIZE) build config/crd | kubectl delete -f -
77+
78+
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
79+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
80+
$(KUSTOMIZE) build config/default | kubectl apply -f -
81+
82+
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
83+
$(KUSTOMIZE) build config/default | kubectl delete -f -
84+
85+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
86+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
87+
88+
.PHONY: kustomize
89+
KUSTOMIZE = $(shell pwd)/bin/kustomize
90+
kustomize: ## Download kustomize locally if necessary.
91+
ifeq (,$(wildcard $(KUSTOMIZE)))
92+
ifeq (,$(shell which kustomize 2>/dev/null))
93+
@{ \
94+
set -e ;\
95+
mkdir -p $(dir $(KUSTOMIZE)) ;\
96+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.8.7/kustomize_v3.8.7_$(OS)_$(ARCH).tar.gz | \
97+
tar xzf - -C bin/ ;\
98+
}
99+
else
100+
KUSTOMIZE = $(shell which kustomize)
101+
endif
102+
endif
103+
104+
.PHONY: helm-operator
105+
HELM_OPERATOR = $(shell pwd)/bin/helm-operator
106+
helm-operator: ## Download helm-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
107+
ifeq (,$(wildcard $(HELM_OPERATOR)))
108+
ifeq (,$(shell which helm-operator 2>/dev/null))
109+
@{ \
110+
set -e ;\
111+
mkdir -p $(dir $(HELM_OPERATOR)) ;\
112+
curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.15.0/helm-operator_$(OS)_$(ARCH) ;\
113+
chmod +x $(HELM_OPERATOR) ;\
114+
}
115+
else
116+
HELM_OPERATOR = $(shell which helm-operator)
117+
endif
118+
endif
119+
120+
.PHONY: bundle
121+
bundle: kustomize ## Generate bundle manifests and metadata, then validate generated files.
122+
operator-sdk generate kustomize manifests -q
123+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
124+
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
125+
operator-sdk bundle validate ./bundle
126+
127+
.PHONY: bundle-build
128+
bundle-build: ## Build the bundle image.
129+
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
130+
131+
.PHONY: bundle-push
132+
bundle-push: ## Push the bundle image.
133+
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
134+
135+
.PHONY: opm
136+
OPM = ./bin/opm
137+
opm: ## Download opm locally if necessary.
138+
ifeq (,$(wildcard $(OPM)))
139+
ifeq (,$(shell which opm 2>/dev/null))
140+
@{ \
141+
set -e ;\
142+
mkdir -p $(dir $(OPM)) ;\
143+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$(OS)-$(ARCH)-opm ;\
144+
chmod +x $(OPM) ;\
145+
}
146+
else
147+
OPM = $(shell which opm)
148+
endif
149+
endif
150+
151+
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
152+
# These images MUST exist in a registry and be pull-able.
153+
BUNDLE_IMGS ?= $(BUNDLE_IMG)
154+
155+
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
156+
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
157+
158+
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
159+
ifneq ($(origin CATALOG_BASE_IMG), undefined)
160+
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
161+
endif
162+
163+
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
164+
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
165+
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
166+
.PHONY: catalog-build
167+
catalog-build: opm ## Build a catalog image.
168+
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
169+
170+
# Push the catalog image.
171+
.PHONY: catalog-push
172+
catalog-push: ## Push a catalog image.
173+
$(MAKE) docker-push IMG=$(CATALOG_IMG)

PROJECT

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
domain: external-secrets.io
2+
layout:
3+
- helm.sdk.operatorframework.io/v1
4+
plugins:
5+
manifests.sdk.operatorframework.io/v2: {}
6+
scorecard.sdk.operatorframework.io/v2: {}
7+
projectName: external-secrets-operator
8+
resources:
9+
- api:
10+
crdVersion: v1
11+
namespaced: true
12+
domain: external-secrets.io
13+
group: operator
14+
kind: OperatorConfig
15+
version: v1alpha1
16+
version: "3"

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
# external-secrets-operator
1+
# external-secrets-operator
2+
3+
K8s operator based on operator-sdk framework to install external-secrets operator helm chart from https://github.com/external-secrets/external-secrets
4+
5+
Initial operator bootstrap created with:
6+
```bash
7+
$ operator-sdk init --plugins helm --group operator --domain external-secrets.io --version v1alpha1 --kind OperatorConfig --helm-chart=external-secrets --helm-chart-repo=https://charts.external-secrets.io/ --helm-chart-version=0.3.8
8+
Writing kustomize manifests for you to edit...
9+
Creating the API:
10+
$ operator-sdk create api --group operator --version v1alpha1 --kind OperatorConfig --helm-chart external-secrets --helm-chart-repo https://charts.external-secrets.io/ --helm-chart-version 0.3.8
11+
Writing kustomize manifests for you to edit...
12+
Created helm-charts/external-secrets
13+
Generating RBAC rules
14+
WARN[0006] Using default RBAC rules: failed to generate RBAC rules: failed to get server resources: Unauthorized
15+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: operatorconfigs.operator.external-secrets.io
6+
spec:
7+
group: operator.external-secrets.io
8+
names:
9+
kind: OperatorConfig
10+
listKind: OperatorConfigList
11+
plural: operatorconfigs
12+
singular: operatorconfig
13+
scope: Namespaced
14+
versions:
15+
- name: v1alpha1
16+
schema:
17+
openAPIV3Schema:
18+
description: OperatorConfig is the Schema for the operatorconfigs API
19+
properties:
20+
apiVersion:
21+
description: 'APIVersion defines the versioned schema of this representation
22+
of an object. Servers should convert recognized schemas to the latest
23+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
24+
type: string
25+
kind:
26+
description: 'Kind is a string value representing the REST resource this
27+
object represents. Servers may infer this from the endpoint the client
28+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
29+
type: string
30+
metadata:
31+
type: object
32+
spec:
33+
description: Spec defines the desired state of OperatorConfig
34+
type: object
35+
x-kubernetes-preserve-unknown-fields: true
36+
status:
37+
description: Status defines the observed state of OperatorConfig
38+
type: object
39+
x-kubernetes-preserve-unknown-fields: true
40+
type: object
41+
served: true
42+
storage: true
43+
subresources:
44+
status: {}

config/crd/kustomization.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This kustomization.yaml is not intended to be run by itself,
2+
# since it depends on service name and namespace that are out of this kustomize package.
3+
# It should be run by config/default
4+
resources:
5+
- bases/operator.external-secrets.io_operatorconfigs.yaml
6+
#+kubebuilder:scaffold:crdkustomizeresource

config/default/kustomization.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Adds namespace to all resources.
2+
namespace: external-secrets-operator-system
3+
4+
# Value of this field is prepended to the
5+
# names of all resources, e.g. a deployment named
6+
# "wordpress" becomes "alices-wordpress".
7+
# Note that it should also match with the prefix (text before '-') of the namespace
8+
# field above.
9+
namePrefix: external-secrets-operator-
10+
11+
# Labels to add to all resources and selectors.
12+
#commonLabels:
13+
# someName: someValue
14+
15+
bases:
16+
- ../crd
17+
- ../rbac
18+
- ../manager
19+
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
20+
#- ../prometheus
21+
22+
patchesStrategicMerge:
23+
# Protect the /metrics endpoint by putting it behind auth.
24+
# If you want your controller-manager to expose the /metrics
25+
# endpoint w/o any authn/z, please comment the following line.
26+
- manager_auth_proxy_patch.yaml
27+
28+
# Mount the controller config file for loading manager configurations
29+
# through a ComponentConfig type
30+
#- manager_config_patch.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This patch inject a sidecar container which is a HTTP proxy for the
2+
# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: controller-manager
7+
namespace: system
8+
spec:
9+
template:
10+
spec:
11+
containers:
12+
- name: kube-rbac-proxy
13+
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
14+
args:
15+
- "--secure-listen-address=0.0.0.0:8443"
16+
- "--upstream=http://127.0.0.1:8080/"
17+
- "--logtostderr=true"
18+
- "--v=10"
19+
ports:
20+
- containerPort: 8443
21+
protocol: TCP
22+
name: https
23+
- name: manager
24+
args:
25+
- "--health-probe-bind-address=:8081"
26+
- "--metrics-bind-address=127.0.0.1:8080"
27+
- "--leader-elect"
28+
- "--leader-election-id=external-secrets-operator"
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: controller-manager
5+
namespace: system
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: manager
11+
args:
12+
- "--config=controller_manager_config.yaml"
13+
volumeMounts:
14+
- name: manager-config
15+
mountPath: /controller_manager_config.yaml
16+
subPath: controller_manager_config.yaml
17+
volumes:
18+
- name: manager-config
19+
configMap:
20+
name: manager-config
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
2+
kind: ControllerManagerConfig
3+
health:
4+
healthProbeBindAddress: :8081
5+
metrics:
6+
bindAddress: 127.0.0.1:8080
7+
8+
leaderElection:
9+
leaderElect: true
10+
resourceName: 811c9dc5.external-secrets.io

config/manager/kustomization.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
resources:
2+
- manager.yaml
3+
4+
generatorOptions:
5+
disableNameSuffixHash: true
6+
7+
configMapGenerator:
8+
- name: manager-config
9+
files:
10+
- controller_manager_config.yaml

0 commit comments

Comments
 (0)