Skip to content

Commit

Permalink
Update and rework OLM bundle creation (#898)
Browse files Browse the repository at this point in the history
* Update operator-sdk

Signed-off-by: Christoph Stäbler <[email protected]>

* Fix operator rbac

Signed-off-by: Christoph Stäbler <[email protected]>

* Rework bundle generation

* Added a base clusterserviceversion with default values for the
  generated csv.
* Moved the nncp and nmstate CRs into the examples directory so they
  will be included in the CSV.

Signed-off-by: Christoph Stäbler <[email protected]>
  • Loading branch information
creydr authored Nov 25, 2021
1 parent be1ec49 commit 6692944
Show file tree
Hide file tree
Showing 20 changed files with 1,062 additions and 293 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ OPERATOR_SDK ?= $(GOBIN)/operator-sdk

GINKGO = go run github.com/onsi/ginkgo/ginkgo
CONTROLLER_GEN = go run sigs.k8s.io/controller-tools/cmd/controller-gen
OPM = go run github.com/operator-framework/operator-registry/cmd/opm
OPM = go run -tags=json1 github.com/operator-framework/operator-registry/cmd/opm

LOCAL_REGISTRY ?= registry:5000

Expand Down Expand Up @@ -122,7 +122,7 @@ lint: $(GO)
hack/lint.sh

$(OPERATOR_SDK):
curl https://github.com/operator-framework/operator-sdk/releases/download/v1.7.1/operator-sdk_linux_amd64 -o $(OPERATOR_SDK)
curl https://github.com/operator-framework/operator-sdk/releases/download/v1.15.0/operator-sdk_linux_amd64 -o $(OPERATOR_SDK)

gen-k8s: $(GO)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
Expand Down Expand Up @@ -206,6 +206,7 @@ vendor: $(GO)

# Generate bundle manifests and metadata, then validate generated files.
bundle: $(OPERATOR_SDK) gen-crds manifests
cp -r deploy/bases $(MANIFESTS_DIR)/bases
$(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) --deploy-dir $(MANIFESTS_DIR) --crds-dir deploy/crds
$(OPERATOR_SDK) bundle validate ./bundle

Expand All @@ -215,7 +216,7 @@ bundle-build:

# Build the index
index-build: $(GO) bundle-build
$(OPM) index add --bundles $(BUNDLE_IMG) --tag $(INDEX_IMG)
$(OPM) index add --bundles $(BUNDLE_IMG) --tag $(INDEX_IMG) --build-tool $(IMAGE_BUILDER)

bundle-push: bundle-build
$(IMAGE_BUILDER) push $(BUNDLE_IMG)
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
domain: nmstate.io
layout:
- go.kubebuilder.io/v3
projectName: kubernetes-nmstate
projectName: kubernetes-nmstate-operator
repo: github.com/nmstate/kubernetes-nmstate
resources:
- api:
Expand Down
14 changes: 10 additions & 4 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
FROM scratch

# Core bundle labels.
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=kubernetes-nmstate
LABEL operators.operatorframework.io.bundle.package.v1=kubernetes-nmstate-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-unknown
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.13.0+git
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v2
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/

# Copy files to locations specified by labels.
COPY bundle/manifests /manifests/
COPY bundle/metadata /metadata/
COPY bundle/tests/scorecard /tests/scorecard/
163 changes: 115 additions & 48 deletions bundle/manifests/kubernetes-nmstate-operator.clusterserviceversion.yaml

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions bundle/manifests/nmstate-operator_v1_serviceaccount.yaml

This file was deleted.

257 changes: 256 additions & 1 deletion bundle/manifests/nmstate.io_nmstates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
controller-gen.kubebuilder.io/version: v0.6.0
creationTimestamp: null
name: nmstates.nmstate.io
spec:
Expand Down Expand Up @@ -34,6 +34,58 @@ spec:
spec:
description: NMStateSpec defines the desired state of NMState
properties:
infraNodeSelector:
additionalProperties:
type: string
description: InfraNodeSelector is an optional selector that will be
added to webhook & certmanager Deployment manifests If InfraNodeSelector
is specified, the webhook and certmanager will run only on nodes
that have each of the indicated key-value pairs as labels applied
to the node.
type: object
infraTolerations:
description: InfraTolerations is an optional list of tolerations to
be added to webhook & certmanager Deployment manifests If InfraTolerations
is specified, the webhook and certmanager will be able to be scheduled
on nodes with corresponding taints
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match all
values and all keys.
type: string
operator:
description: Operator represents a key's relationship to the
value. Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod
can tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time
the toleration (which must be of effect NoExecute, otherwise
this field is ignored) tolerates the taint. By default, it
is not set, which means tolerate the taint forever (do not
evict). Zero and negative values will be treated as 0 (evict
immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
nodeSelector:
additionalProperties:
type: string
Expand All @@ -44,6 +96,49 @@ spec:
that have each of the indicated key-value pairs as labels applied
to the node.
type: object
tolerations:
description: Tolerations is an optional list of tolerations to be
added to handler DaemonSet manifest If Tolerations is specified,
the handler daemonset will be also scheduled on nodes with corresponding
taints
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match all
values and all keys.
type: string
operator:
description: Operator represents a key's relationship to the
value. Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod
can tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time
the toleration (which must be of effect NoExecute, otherwise
this field is ignored) tolerates the taint. By default, it
is not set, which means tolerate the taint forever (do not
evict). Zero and negative values will be treated as 0 (evict
immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
type: object
status:
description: NMStateStatus defines the observed state of NMState
Expand All @@ -59,6 +154,8 @@ spec:
type: string
message:
type: string
messageEncoded:
type: string
reason:
type: string
status:
Expand All @@ -74,6 +171,164 @@ spec:
type: object
served: true
storage: true
- deprecated: true
name: v1beta1
schema:
openAPIV3Schema:
description: NMState is the Schema for the nmstates API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: NMStateSpec defines the desired state of NMState
properties:
infraNodeSelector:
additionalProperties:
type: string
description: InfraNodeSelector is an optional selector that will be
added to webhook & certmanager Deployment manifests If InfraNodeSelector
is specified, the webhook and certmanager will run only on nodes
that have each of the indicated key-value pairs as labels applied
to the node.
type: object
infraTolerations:
description: InfraTolerations is an optional list of tolerations to
be added to webhook & certmanager Deployment manifests If InfraTolerations
is specified, the webhook and certmanager will be able to be scheduled
on nodes with corresponding taints
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match all
values and all keys.
type: string
operator:
description: Operator represents a key's relationship to the
value. Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod
can tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time
the toleration (which must be of effect NoExecute, otherwise
this field is ignored) tolerates the taint. By default, it
is not set, which means tolerate the taint forever (do not
evict). Zero and negative values will be treated as 0 (evict
immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector is an optional selector that will be added
to handler DaemonSet manifest for both workers and control-plane
(https://github.com/nmstate/kubernetes-nmstate/blob/main/deploy/handler/operator.yaml).
If NodeSelector is specified, the handler will run only on nodes
that have each of the indicated key-value pairs as labels applied
to the node.
type: object
tolerations:
description: Tolerations is an optional list of tolerations to be
added to handler DaemonSet manifest If Tolerations is specified,
the handler daemonset will be also scheduled on nodes with corresponding
taints
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match all
values and all keys.
type: string
operator:
description: Operator represents a key's relationship to the
value. Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod
can tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time
the toleration (which must be of effect NoExecute, otherwise
this field is ignored) tolerates the taint. By default, it
is not set, which means tolerate the taint forever (do not
evict). Zero and negative values will be treated as 0 (evict
immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
type: object
status:
description: NMStateStatus defines the observed state of NMState
properties:
conditions:
items:
properties:
lastHearbeatTime:
format: date-time
type: string
lastTransitionTime:
format: date-time
type: string
message:
type: string
messageEncoded:
type: string
reason:
type: string
status:
type: string
type:
type: string
required:
- status
- type
type: object
type: array
type: object
type: object
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down
Loading

0 comments on commit 6692944

Please sign in to comment.