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

Add task to build operator bundle #2929

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ generate-operator-bundle: manifests
# the bundle.
rm bundle/manifests/azureoperator-webhook-service_v1_service.yaml
# Inject the container reference into the bundle.
scripts/inject-container-reference.sh "$(PUBLIC_REPO):$(LATEST_TAG)"
scripts/inject-container-reference.sh "$(PUBLIC_REPO):$(LATEST_TAG)" "bundle/manifests/azure-service-operator.clusterserviceversion.yaml"
# Update webhooks to use operator namespace and remove
# cert-manager annotations.
scripts/update-webhook-references-in-operator-bundle.sh
Expand Down
24 changes: 24 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -954,3 +954,27 @@ tasks:
dir: v2/tools/mangle-test-json
cmds:
- go build

generate-operator-bundle:
desc: Generates an operator bundle for ASOv2
deps: [ controller:generate-kustomize ]
cmds:
- ./scripts/gen-operatorbundle-samples-manifest.sh ./v2/samples ./v2/config/samples
- rm -rf "bundle/manifests"
- kustomize build "{{.CONTROLLER_OUTPUT}}/operator-bundle" | operator-sdk generate bundle --version "{{.VERSION_TAG}}" --channels stable --default-channel stable --overwrite --kustomize-dir "{{.CONTROLLER_OUTPUT}}/operator-bundle"
# Remove the webhook service - OLM will create one when installing
# the bundle.
- rm bundle/manifests/azureserviceoperator-webhook-service_v1_service.yaml
# Inject the container reference into the bundle.
- scripts/inject-container-reference.sh "{{.PUBLIC_REGISTRY}}:{{.CONTROLLER_DOCKER_IMAGE}}" "bundle/manifests/azure-service-operator.clusterserviceversion.yaml"
# Update webhooks to use operator namespace and remove
# cert-manager annotations.
- scripts/update-webhook-references-in-operator-bundle.sh
# Include the replaces field with the old version. TODO: Un-comment this once we're building 2.1.0 operator
# - yq eval -i ".spec.replaces = \"azure-service-operator.{{.PREVIOUS_VERSION}}\"" bundle/manifests/azure-service-operator.clusterserviceversion.yaml
# Rename the csv to simplify adding to the community-operators repo for a PR
- yq eval -i '(.metadata.labels[] | select(. == "${VERSION}")) = "{{.LATEST_VERSION_TAG}}"' ./bundle/manifests/*
- mv bundle/manifests/azure-service-operator.clusterserviceversion.yaml bundle/manifests/azure-service-operator.{{.VERSION_TAG}}.clusterserviceversion.yaml
vars:
VERSION_TAG:
sh: echo {{.LATEST_VERSION_TAG}} | sed 's/^.//' # opertator-sdk does not allow the version tag to be in a v2.0.0 format, so we have to trim it here to be in a 2.0.0 format.
34 changes: 34 additions & 0 deletions scripts/gen-operatorbundle-samples-manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

# Kustomize throws an error if the resources are not in the same root directory.
# Hence, we need this script to put samples in one place for operator-bundle.

set -o errexit
set -o nounset
set -o pipefail

SAMPLES_DIR=$1
OUT_DIR=$2

rm -rf "$OUT_DIR"
mkdir "$OUT_DIR"
echo "resources: " > "$OUT_DIR/kustomization.yaml"

for filepath in $(find "$SAMPLES_DIR" -type f); do

FILENAME=$(basename $filepath)
if
[[ $filepath == *"refs"* ]] ||
[[ $filepath != *"v1api"* ]] ||
grep -q "$FILENAME" "$OUT_DIR/kustomization.yaml";
then
continue
fi

cp $filepath "$OUT_DIR"
echo " - $FILENAME" >> "$OUT_DIR/kustomization.yaml"

done
4 changes: 2 additions & 2 deletions scripts/inject-container-reference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
set -euo pipefail

container_reference="$1"
now="$(date --rfc-3339=seconds)"
cluster_version_file="bundle/manifests/azure-service-operator.clusterserviceversion.yaml"
cluster_version_file=$2
now="$(date -u)"

# Replace the controller:latest reference in the deployment (embedded
# in the CSV) with the SHA one.
Expand Down
4 changes: 2 additions & 2 deletions scripts/update-webhook-references-in-operator-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -euo pipefail

# Find all of the CRDs that have conversion webhooks defined
# (filtering out the --- separators yq puts between them).
query='select(.spec.conversion.webhook.clientConfig.service.namespace == "azureoperator-system") | filename'
webhook_crds=$(yq eval "$query" bundle/manifests/azure.microsoft.com_*.yaml | grep -v -e "---")
query='select(.spec.conversion.webhook.clientConfig.service.namespace == "azureserviceoperator-system") | filename'
webhook_crds=$(yq eval "$query" bundle/manifests/*.azure.com_*.yaml | grep -v -e "---")

# Remove the cert-manager annotation and conversion details from CRDs
# with conversion webhooks - OLM will set up the conversion structure
Expand Down
1 change: 1 addition & 0 deletions v2/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config/crd/generated
config/webhook/manifests.yaml
config/rbac/role.yaml
config/samples
out/
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
annotations:
capabilities: Deep Insights
categories: Cloud Provider
certified: "false"
description: The Azure Service Operator helps you provision Azure resources and connect your applications to them from within Kubernetes.
displayName: Azure Service Operator V2
repository: https://github.com/Azure/azure-service-operator
support: https://github.com/Azure/azure-service-operator/issues
name: azure-service-operator.X.Y.Z
namespace: placeholder
spec:
apiservicedefinitions: {}
customresourcedefinitions: {}
description: |
## Overview

The Azure Service Operator comprises of:

- The Custom Resource Definitions (CRDs) for each of the Azure services a Kubernetes user can provision.
- The Kubernetes controller that watches for requests to create Custom Resources for each of these CRDs and creates them.

The project was built using [Kubebuilder](https://book.kubebuilder.io/).

## Supported Azure Resources

Supported Azure Resources can be found on our official documentation for [Supported Resources](https://azure.github.io/azure-service-operator/reference/)

## Instructions - Please read before installing

Before you begin, read our documentation on authentication and multiple types of multitenancy ASOv2 supports [here](https://azure.github.io/azure-service-operator/guide/authentication/)

## About the project

This project maintains [releases of the Azure Service Operator](https://github.com/Azure/azure-service-operator/releases).

Please see the [FAQ](https://azure.github.io/azure-service-operator/guide/frequently-asked-questions/) for answers to commonly asked questions about the Azure Service Operator.

Have more questions? Feel free to consult our documentation [here](https://github.com/Azure/azure-service-operator/blob/main/docs/v1/howto/contents.md).

## Contributing

The [contribution guide](https://azure.github.io/azure-service-operator/contributing/) covers everything you need to know about how you can contribute to Azure Service Operators. The [developer guide](https://github.com/Azure/azure-service-operator/blob/main/docs/v1/howto/contents.md#developing-azure-service-operator) will help you onboard as a developer.

## Support

Azure Service Operator is an open source project that is **not** covered by the [Microsoft Azure support policy](https://support.microsoft.com/en-us/help/2941892/support-for-linux-and-open-source-technology-in-azure). Please search open issues [here](https://github.com/Azure/azure-service-operator/issues). If your issue isn't already represented, please [open a new one](https://github.com/Azure/azure-service-operator/issues/new/choose). The Azure Service Operator project maintainers will respond to the best of their abilities.

## Code of conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

displayName: Azure Service Operator
icon:
- base64data: 'iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAIAAAAP3aGbAAAACXBIWXMAAAsSAAALEgHS3X78AAAFg0lEQVR4nO3bsU0DQRBA0VvkFIkeqAVyYppxM8TkuBZ6QKKAoQMTWfK/e6+C3R3pa5JdM7MBFDyYElAhWECGYAEZggVkCBaQIVhAhmABGYIFZAgWkCFYQIZgARmCBWQIFpAhWECGYAEZggVkCBaQIVhAhmABGYIFZAgWkCFYQIZgARmCBWQIFpAhWECGYAEZggVkCBaQIVhAhmABGYIFZAgWkCFYQIZgARmCBWQIFpAhWECGYAEZggVkCBaQIVhAhmABGYIF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IEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBjzYxpAQk2LCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECMgQLyBAsIEOwgAzBAjIEC8gQLCBDsIAMwQIyBAvIECwgQ7CADMECGrZt+wNsYxcZUVWjkAAAAABJRU5ErkJggg== '
mediatype: image/png
install:
spec:
clusterPermissions:
- rules: null
serviceAccountName: azure-service-operator-default
deployments: []
permissions:
- rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- ""
resources:
- configmaps/status
verbs:
- get
- update
- patch
serviceAccountName: azure-service-operator-default
strategy: deployment
installModes:
- supported: false
type: OwnNamespace
- supported: false
type: SingleNamespace
- supported: false
type: MultiNamespace
- supported: true
type: AllNamespaces
keywords:
- azure, microsoft, cloud service broker
links:
- name: Azure Service Operator
url: https://github.com/Azure/azure-service-operator
maintainers:
- email: [email protected]
name: ASO team
maturity: stable
provider:
name: Microsoft
version: 0.0.0
3 changes: 3 additions & 0 deletions v2/config/operator-bundle/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- ../default
- ../samples