Skip to content

Commit

Permalink
Add docs and sample generated bundle
Browse files Browse the repository at this point in the history
Add a generated bundle for kubernetes platform.

Add docs on the bundle generation tool and on bundle geration for
kubernetes.

Signed-off-by: Nikhil Thomas <[email protected]>
  • Loading branch information
nikhil-thomas committed Sep 3, 2021
1 parent ee0a2cb commit 3bb89e3
Show file tree
Hide file tree
Showing 48 changed files with 332 additions and 1,512 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ $(BIN)/golangci-lint: | $(BIN) ; $(info $(M) getting golangci-lint $(GOLANGCI_VE

.PHONY: clean-cluster
clean-cluster: | $(KO) $(KUSTOMIZE) clean-cr; $(info $(M) clean $(TARGET)…) @ ## Cleanup cluster
@ ## --load-restrictor LoadRestrictionsNone is needed in kustomize build as files which not in child tree of kustomize base are pulled
@ ## https://github.com/kubernetes-sigs/kustomize/issues/766
-$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/$(TARGET) | $(KO) delete -f -
-kubectl delete ns tekton-pipelines --ignore-not-found
-kubectl delete \
Expand Down Expand Up @@ -89,6 +91,8 @@ get-releases: |

.PHONY: apply
apply: | $(KO) $(KUSTOMIZE) get-releases ; $(info $(M) ko apply on $(TARGET)) @ ## Apply config to the current cluster
@ ## --load-restrictor LoadRestrictionsNone is needed in kustomize build as files which not in child tree of kustomize base are pulled
@ ## https://github.com/kubernetes-sigs/kustomize/issues/766
$Q $(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/$(TARGET) | $(KO) apply $(PLATFORM) -f -

.PHONY: apply-cr
Expand All @@ -101,6 +105,8 @@ clean-cr: | ; $(info $(M) clean CRs on $(TARGET)) @ ## Clean the CRs to the curr

.PHONY: resolve
resolve: | $(KO) $(KUSTOMIZE) get-releases ; $(info $(M) ko resolve on $(TARGET)) @ ## Resolve config to the current cluster
@ ## --load-restrictor LoadRestrictionsNone is needed in kustomize build as files which not in child tree of kustomize base are pulled
@ ## https://github.com/kubernetes-sigs/kustomize/issues/766
$Q $(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/$(TARGET) | $(KO) resolve --push=false --oci-layout-path=$(BIN)/oci -f -

.PHONY: generated
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,31 @@ on any Kubernetes Cluster.
$ kubectl apply -f https://raw.githubusercontent.com/tektoncd/operator/main/config/crs/kubernetes/config/all/operator_v1alpha1_config_cr.yaml
```

# References
# Detailed Documentation

- [Development Guide](docs/README.md)
- [Testing Guide](test/README.md)
[Concepts and Guides](docs/README.md)

### Read the docs
# Development Guide

[Development Guide](docs/README.md)

# Running E2E tests

[Testing Guide](test/README.md)

# Release Guide

[How to make a TektonCD/Operator Release](tekton/README.md)

# Gerating OperatorHub Bundle(s)

[OperatorHub Bundles](operatorhub/README.md)

# Roadmap

[Roadmap](./ROADMAP.md)

# Read the docs

| Version | Docs |
| ------- | ---- |
Expand Down
2 changes: 1 addition & 1 deletion config/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ resources:
- role_binding.yaml
- operator.yaml
- webhook.yaml
- webhook-service.yaml
- webhook-service.yaml
4 changes: 0 additions & 4 deletions config/base/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ metadata:
version: "devel"
operator.tekton.dev/release: "devel"
spec: {}
- name: VERSION
value: "devel"
- name: METRICS_DOMAIN
value: tekton.dev/operator
2 changes: 0 additions & 2 deletions config/base/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ metadata:
version: "devel"
operator.tekton.dev/release: "devel"
spec: {}
- name: METRICS_DOMAIN
value: tekton.dev/operator
14 changes: 14 additions & 0 deletions config/kubernetes/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ spec:
value: ko://github.com/tektoncd/operator/cmd/kubernetes/proxy-webhook
- name: IMAGE_JOB_PRUNER_TKN
value: gcr.io/tekton-releases/dogfooding/tkn@sha256:f69a02ef099d8915e9e4ea1b74e43b7a9309fc97cf23cb457ebf191e73491677
- name: METRICS_DOMAIN
value: tekton.dev/operator
- name: VERSION
value: "devel"
- name: AUTOINSTALL_COMPONENTS
valueFrom:
configMapKeyRef:
name: tekton-config-defaults
key: AUTOINSTALL_COMPONENTS
- name: DEFAULT_TARGET_NAMESPACE
valueFrom:
configMapKeyRef:
name: tekton-config-defaults
key: DEFAULT_TARGET_NAMESPACE
2 changes: 2 additions & 0 deletions config/kubernetes/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
value: tekton-operator-webhook
- name: WEBHOOK_SECRET_NAME
value: tekton-operator-webhook-certs
- name: METRICS_DOMAIN
value: tekton.dev/operator
ports:
- name: https-webhook
containerPort: 8443
14 changes: 14 additions & 0 deletions config/openshift/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,19 @@ spec:
value: ko://github.com/tektoncd/operator/cmd/openshift/proxy-webhook
- name: IMAGE_JOB_PRUNER_TKN
value: gcr.io/tekton-releases/dogfooding/tkn@sha256:f69a02ef099d8915e9e4ea1b74e43b7a9309fc97cf23cb457ebf191e73491677
- name: METRICS_DOMAIN
value: tekton.dev/operator
- name: VERSION
value: "devel"
- name: AUTOINSTALL_COMPONENTS
valueFrom:
configMapKeyRef:
name: tekton-config-defaults
key: AUTOINSTALL_COMPONENTS
- name: DEFAULT_TARGET_NAMESPACE
valueFrom:
configMapKeyRef:
name: tekton-config-defaults
key: DEFAULT_TARGET_NAMESPACE
# - name: IMAGE_ADDONS_PARAM_TKN_IMAGE
# value: gcr.io/tekton-releases/dogfooding/tkn@sha256:f69a02ef099d8915e9e4ea1b74e43b7a9309fc97cf23cb457ebf191e73491677
2 changes: 2 additions & 0 deletions config/openshift/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
value: tekton-operator-webhook
- name: WEBHOOK_SECRET_NAME
value: tekton-operator-webhook-certs
- name: METRICS_DOMAIN
value: tekton.dev/operator
ports:
- name: https-webhook
containerPort: 8443
65 changes: 62 additions & 3 deletions operatorhub/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,68 @@
# Generating Bundles (release artifact) for OperatorHub

1. From project root run:
We can use [bundle.py](./tools/bundle.py) tool to generate operator bundles. The tool takes in
a list of Kubernetes resource definitions (Deployment, Role, Rolebinding, ConfigMaps ...) and
some metadata (bundle description, release channels, bundle icon graphic... ) and outputs operator bundle.

## Quick Links

1. [Generating Operator Bundle for Kubernetes](./kubernetes/README.md)
1. [Generating Operator Bundle for OpenShift](./openshift/README.md)

## Concepts

### Bundle Generation "Strategies"

The bundle generation strategy specifies how the tool accumulates input (list of kubernetes resources).
Two strategies are supported:

1. **release-manifest**: input files are collected from a pre-existing release.yaml file. This release.yaml
could be from an already existing github release or from the result of `ko resolve cofig`.

2. **local:** All input files are gathered in realtime from local repository extensive usage of `kustomize`.

### Update Strategies

An update strategy defines the update relations of the current bundle with the previous releases (bundles).
The bundle generation tool supports 2 update strategies.

1. **semver**: OLM will upgrade opertor to a bundle with higher semver version, in the current subscription channel
2. **replaces**: OLM will follow explict `spec.replaces: <previous version>` filed specification

more details: [semver-mode, replaces mode](https://k8s-operatorhub.github.io/community-operators/packaging-operator/)


## Conventions

The tool expects the following directory structure and a config.yaml for each platform.

```bash
export BUNDLE_ARGS="--workspace=operatorhub/kubernetes --operator-release-version=1.1.1 --channels=a,b --default-channel=a --fetch-strategy-local --upgrade-strategy-semver"
make bundle
kubernetes
├── config.yaml
├── manifests
│ ├── bases
│ │ └── tektoncd-operator.clusterserviceversion.template.yaml
│ ├── fetch-strategy-local
│ │ └── kustomization.yaml
│ └── fetch-strategy-release-manifest
│ └── kustomization.yaml
```

## CLI flags

[bundle.py cli flags](./tools/bundle-too-cli-flags.md)

## Specifying Image Overrides using config.yaml

[bunele generation config.yaml](./tools/CONFIG-DEFINITION.md)

## Operator LifeCycle Manager Concepts

- [Operator Bundle](https://operator-sdk.netlify.app/docs/olm-integration/quickstart-bundle/)
- [ClusterServiceVersion CRD](https://olm.operatorframework.io/docs/concepts/crds/clusterserviceversion/)

# References

2. [Operator Lifecycle Manager (OLM) Documentation](https://olm.operatorframework.io/docs/)
3. [Operator SDK OLM Integration Documentation](https://operator-sdk.netlify.app/docs/olm-integration/)
4. [OperatorHub (Community Operators) Documentation](https://k8s-operatorhub.github.io/community-operators/packaging-operator/)
34 changes: 34 additions & 0 deletions operatorhub/kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# How to generate Operator Bundles for OpenShift

For Kubernetes Platform ([operatorhub.io](https://operatorhub.io)) release we generate the
bundle for using `release-manifest` strategy.

## Steps to generate bundles from an existing release.yaml

**Note:** The input release.yaml could be a github release or the result of `ko resolve config`

1. Make sure that we have the release manifest file ready
eg:
```bash
curl -L -o tektoncd-operator-0.49.0 https://github.com/tektoncd/operator/releases/download/v0.49.0/release.notags.yaml
```

2. From the project root (tektoncd/operator) run

```bash
export BUNDLE_ARGS='--workspace operatorhub/kubernetes --operator-release-version 0.49.0 --channels alpha --default-channel alpha --fetch-strategy-release-manifest --release-manifest tektoncd-operator-0.49.0 --upgrade-strategy-semver'
make operator-bundle
```

**CLI flags explained**

Flag | Description
--------------------------------------------- | -----------
`--workspace operatorhub/kubernetes` | the working directory where the operator bundle should be assembled
`--operator-release-version 0.49.0` | version of the release (version of bundle)
`--channels alpha` | target release channel(s) (eg: stable,preview)
`--default-channel alpha` | set default channel of the operator
`--fetch-strategy-release-manifest` | gather input kubernetes resources from a list of yaml manifests instead of using local files
`--release-manifest tektoncd-operaotr-0.49.0` | specify release manifest file
`--upgrade-strategy-semver` | specify update strategy (use `replaces` or `semver`)
````
4 changes: 2 additions & 2 deletions operatorhub/kubernetes/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
platform: "kubernetes"
operator-packagename: "tektoncd-operator"
image-substitutions:
- image: ko://github.com/tektoncd/operator/cmd/kubernetes/operator:develContainer
- image: ko://github.com/tektoncd/operator/cmd/kubernetes/operator:devel
replaceLocations:
containerTargets:
- deploymentName: tekton-operator
Expand All @@ -13,7 +13,7 @@ image-substitutions:
containerName: tekton-operator
envKeys:
- IMAGE_PIPELINES_PROXY
- image: gcr.io/tekton-releases/dogfooding/tkn@sha256:f69a02ef099d8915e9e4ea1b74e43b7a9309fc97cf23cb457ebf191e73491677DEVEL
- image: gcr.io/tekton-releases/dogfooding/tkn@sha256:f69a02ef099d8915e9e4ea1b74e43b7a9309fc97cf23cb457ebf191e73491677
replaceLocations:
envTargets:
- deploymentName: tekton-operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ resources:
- ../../../../config/kubernetes
- ../../../../config/crs/kubernetes
- ../bases/tektoncd-operator.clusterserviceversion.template.yaml
- ../../scorecard
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resources:
- ../../../../config/crs/kubernetes
- ../bases/tektoncd-operator.clusterserviceversion.template.yaml
- ../../scorecard
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
4 changes: 2 additions & 2 deletions operatorhub/kubernetes/release-artifacts/bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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=tektoncd-operator
LABEL operators.operatorframework.io.bundle.channels.v1=a,b
LABEL operators.operatorframework.io.bundle.channel.default.v1=a
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.7.1+git
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
creationTimestamp: null
labels:
operator.tekton.dev/release: devel
version: devel
version: v0.49.0
name: tektonconfigs.operator.tekton.dev
spec:
group: operator.tekton.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
creationTimestamp: null
labels:
operator.tekton.dev/release: devel
version: devel
version: v0.49.0
name: tektondashboards.operator.tekton.dev
spec:
group: operator.tekton.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
creationTimestamp: null
labels:
operator.tekton.dev/release: devel
version: devel
version: v0.49.0
name: tektonpipelines.operator.tekton.dev
spec:
group: operator.tekton.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
creationTimestamp: null
labels:
operator.tekton.dev/release: devel
version: devel
version: v0.49.0
name: tektonresults.operator.tekton.dev
spec:
group: operator.tekton.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
creationTimestamp: null
labels:
operator.tekton.dev/release: devel
version: devel
version: v0.49.0
name: tektontriggers.operator.tekton.dev
spec:
group: operator.tekton.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ data:
DEFAULT_TARGET_NAMESPACE: tekton-pipelines
kind: ConfigMap
metadata:
annotations: {}
labels:
operator.tekton.dev/release: devel
name: tekton-config-defaults
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: tekton-operator
name: tekton-operator-webhook
operator.tekton.dev/release: devel
version: devel
version: v0.49.0
name: tekton-operator-webhook
spec:
ports:
Expand Down
Loading

0 comments on commit 3bb89e3

Please sign in to comment.