Skip to content

Commit

Permalink
feat: add OCP bundle
Browse files Browse the repository at this point in the history
- generate bundle using Makefile
- build and push bundle using GH actions on new tag

Signed-off-by: Alexander Maslennikov <[email protected]>
  • Loading branch information
almaslennikov committed Dec 24, 2024
1 parent b311edb commit b92a258
Show file tree
Hide file tree
Showing 25 changed files with 1,046 additions and 182 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/image-push-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ on:
push:
tags:
- v*
env:
REGISTRY: "ghcr.io"
OPERATOR_IMAGE_NAME: "maintenance-operator"
jobs:
image-build-push:
name: Image build and push
runs-on: ubuntu-latest
steps:
- name: Set repository as lower-case output variable
id: repo_name
run: echo ::set-output name=repository::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
- name: Set repository owner as lower-case output variable
id: repo_owner
run: echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
Expand All @@ -29,7 +32,7 @@ jobs:
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.repo_name.outputs.repository }}
images: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/${{ env.OPERATOR_IMAGE_NAME }}
tags: |
type=ref,event=tag
flavor: |
Expand All @@ -44,3 +47,30 @@ jobs:
${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile
- name: Determine version, tag, and base branch
run: |
git_tag=${{ github.ref_name }}
echo VERSION_WITH_PREFIX=$git_tag >> $GITHUB_ENV
echo VERSION_WITHOUT_PREFIX=${git_tag:1} >> $GITHUB_ENV # without the 'v' prefix
if echo $git_tag | grep beta; then
base_branch=$DEFAULT_BRANCH
else
v_major_minor=$(echo $git_tag | grep -Eo '^v[0-9]+\.[0-9]+')
base_branch=$v_major_minor.x
fi
echo BASE_BRANCH=$base_branch >> $GITHUB_ENV
- name: Lookup image digest
run: |
operator_digest=$(skopeo inspect docker://$REGISTRY/$REPO_OWNER/$OPERATOR_IMAGE_NAME:$VERSION_WITH_PREFIX | jq -r .Digest)
echo $operator_digest | wc -w | grep 1 # verifies value not empty
echo OPERATOR_DIGEST=$operator_digest >> $GITHUB_ENV
- name: Make bundle
env:
IMG: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/${{ env.OPERATOR_IMAGE_NAME }}@${{ env.OPERATOR_DIGEST }}
BUNDLE_IMG: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/${{ env.OPERATOR_IMAGE_NAME }}-bundle:${{ github.ref_name }}
VERSION: ${{ env.VERSION_WITHOUT_PREFIX }}
run: |
version_major_minor=$(echo $VERSION_WITH_PREFIX | grep -Eo 'v[0-9]+\.[0-9]+')
export CHANNELS=stable,$version_major_minor
export DEFAULT_CHANNEL=$version_major_minor
make bundle bundle-build bundle-push
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif

BUNDLE_OCP_VERSIONS=v4.14-v4.17

# Set the Operator SDK version to use. By default, what is installed on the system is used.
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
OPERATOR_SDK_VERSION ?= v1.35.0
Expand Down Expand Up @@ -414,6 +416,7 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
BUNDLE_OCP_VERSIONS=$(BUNDLE_OCP_VERSIONS) TAG=$(IMG) hack/scripts/ocp-bundle-postprocess.sh
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: bundle-build
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout:
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
projectName: maintenance-operator
projectName: nvidia-maintenance-operator
repo: github.com/Mellanox/maintenance-operator
resources:
- api:
Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha1/maintenanceoperatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,19 @@ type MaintenanceOperatorConfigSpec struct {
MaxNodeMaintenanceTimeSeconds int32 `json:"maxNodeMaintenanceTimeSeconds,omitempty"`
}

type MaintenanceOperatorConfigStatus struct {
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// MaintenanceOperatorConfig is the Schema for the maintenanceoperatorconfigs API
type MaintenanceOperatorConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MaintenanceOperatorConfigSpec `json:"spec,omitempty"`
Spec MaintenanceOperatorConfigSpec `json:"spec,omitempty"`
Status MaintenanceOperatorConfigStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
control-plane: controller-manager
app.kubernetes.io/name: service
app.kubernetes.io/instance: controller-manager-metrics-service
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/component: webhook
app.kubernetes.io/created-by: maintenance-operator
app.kubernetes.io/part-of: maintenance-operator
app.kubernetes.io/instance: webhook-service
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-service
namespace: system
app.kubernetes.io/name: service
app.kubernetes.io/part-of: maintenance-operator
name: maintenance-operator-webhook-service
spec:
ports:
- name: https
port: 8443
- port: 443
protocol: TCP
targetPort: https
targetPort: 9443
selector:
control-plane: controller-manager
status:
loadBalancer: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: maintenance-operator-system/maintenance-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.15.0
creationTimestamp: null
name: maintenanceoperatorconfigs.maintenance.nvidia.com
spec:
group: maintenance.nvidia.com
names:
kind: MaintenanceOperatorConfig
listKind: MaintenanceOperatorConfigList
plural: maintenanceoperatorconfigs
singular: maintenanceoperatorconfig
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: MaintenanceOperatorConfig is the Schema for the maintenanceoperatorconfigs
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: MaintenanceOperatorConfigSpec defines the desired state of
MaintenanceOperatorConfig
properties:
logLevel:
default: info
description: LogLevel is the operator logging level
enum:
- debug
- info
- error
type: string
maxNodeMaintenanceTimeSeconds:
default: 1600
description: |-
MaxNodeMaintenanceTimeSeconds is the time from when a NodeMaintenance is marked as ready (phase: Ready)
until the NodeMaintenance is considered stale and removed by the operator.
should be less than idle time for any autoscaler that is running.
default to 30m (1600 seconds)
format: int32
minimum: 0
type: integer
maxParallelOperations:
anyOf:
- type: integer
- type: string
default: 1
description: |-
MaxParallelOperations indicates the maximal number nodes that can undergo maintenance
at a given time. 0 means no limit
value can be an absolute number (ex: 5) or a percentage of total nodes in the cluster (ex: 10%).
absolute number is calculated from percentage by rounding up.
defaults to 1. The actual number of nodes that can undergo maintenance may be lower depending
on the value of MaintenanceOperatorConfigSpec.MaxUnavailable.
x-kubernetes-int-or-string: true
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
MaxUnavailable is the maximum number of nodes that can become unavailable in the cluster.
value can be an absolute number (ex: 5) or a percentage of total nodes in the cluster (ex: 10%).
absolute number is calculated from percentage by rounding up.
by default, unset.
new nodes will not be processed if the number of unavailable node will exceed this value
x-kubernetes-int-or-string: true
type: object
status:
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: null
storedVersions: null
Loading

0 comments on commit b92a258

Please sign in to comment.