Skip to content

Commit 64758e1

Browse files
Merge pull request #12 from openshift-cherrypick-robot/cherry-pick-11-to-release-4.10
[release-4.10] sync upstream main branch to downstream
2 parents d49d0a5 + 2edb1a3 commit 64758e1

File tree

72 files changed

+4441
-186
lines changed

Some content is hidden

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

72 files changed

+4441
-186
lines changed

.github/workflows/tag-release.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
name: Build and release versioned container images
3+
4+
on:
5+
create
6+
7+
jobs:
8+
tag_bundle:
9+
name: Build and release the bundle container-image
10+
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out the repo
14+
uses: actions/checkout@v2
15+
16+
- name: Install Go 1.17
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: '1.17'
20+
21+
- name: Generate the bundle contents
22+
run: make bundle TAG=${{ github.ref_name }}
23+
24+
- name: Validate the bundle contents
25+
run: make bundle-validate
26+
27+
- name: Login to quay.io
28+
uses: docker/login-action@v1
29+
with:
30+
registry: quay.io
31+
username: ${{ secrets.QUAY_USERNAME }}
32+
password: ${{ secrets.QUAY_PASSWORD }}
33+
34+
- name: Build bundle container image
35+
uses: docker/build-push-action@v2
36+
with:
37+
context: .
38+
file: bundle.Dockerfile
39+
push: true
40+
tags: quay.io/csiaddons/k8s-bundle:${{ github.ref_name }}
41+
42+
tag_controller:
43+
name: Build and release the controller container-image
44+
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Check out the repo
48+
uses: actions/checkout@v2
49+
50+
- name: Set up QEMU
51+
uses: docker/setup-qemu-action@v1
52+
53+
- name: Set up Docker Buildx
54+
uses: docker/setup-buildx-action@v1
55+
56+
- name: Login to quay.io
57+
uses: docker/login-action@v1
58+
with:
59+
registry: quay.io
60+
username: ${{ secrets.QUAY_USERNAME }}
61+
password: ${{ secrets.QUAY_PASSWORD }}
62+
63+
- name: Build and push controller container image
64+
uses: docker/build-push-action@v2
65+
with:
66+
context: .
67+
file: Dockerfile
68+
platforms: linux/amd64,linux/arm64,linux/arm/v7
69+
push: true
70+
tags: quay.io/csiaddons/k8s-controller:${{ github.ref_name }}
71+
72+
tag_sidecar:
73+
name: Build and release the sidecar container-image
74+
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Check out the repo
78+
uses: actions/checkout@v2
79+
80+
- name: Set up QEMU
81+
uses: docker/setup-qemu-action@v1
82+
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v1
85+
86+
- name: Login to quay.io
87+
uses: docker/login-action@v1
88+
with:
89+
registry: quay.io
90+
username: ${{ secrets.QUAY_USERNAME }}
91+
password: ${{ secrets.QUAY_PASSWORD }}
92+
93+
- name: Build and push sidecar container image
94+
uses: docker/build-push-action@v2
95+
with:
96+
context: .
97+
file: build/Containerfile.sidecar
98+
platforms: linux/amd64,linux/arm64,linux/arm/v7
99+
push: true
100+
tags: quay.io/csiaddons/k8s-sidecar:${{ github.ref_name }}

Makefile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11

22
# Image URL to use all building/pushing image targets
3-
IMG ?= quay.io/csiaddons/k8s-controller:latest
3+
CONTROLLER_IMG ?= quay.io/csiaddons/k8s-controller
44
SIDECAR_IMG ?= quay.io/csiaddons/k8s-sidecar
55
BUNDLE_IMG ?= quay.io/csiaddons/k8s-bundle
6-
TAG?= latest
76

8-
BUNDLE_VERSION ?= 0.0.1
7+
# set TAG to a release for consumption in the bundle
8+
TAG ?= latest
9+
10+
# the PACKAGE_NAME is included in the bundle/CSV and is used in catalogsources
11+
# for operators (like OperatorHub.io). Products that include the CSI-Addons
12+
# bundle should use a different PACKAGE_NAME to prevent conflicts.
13+
PACKAGE_NAME ?= csi-addons
14+
15+
# The default version of the bundle (CSV) can be found in
16+
# config/manifests/bases/csi-addons.clusterserviceversion.yaml . When tagging a
17+
# release, the bundle will be versioned with the same value as well.
18+
ifneq ($(TAG),latest)
19+
BUNDLE_VERSION ?= --version=$(shell sed s/^v// <<< $(TAG))
20+
endif
921

1022
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
1123
ENVTEST_K8S_VERSION = 1.23
@@ -47,12 +59,12 @@ help: ## Display this help.
4759

4860
.PHONY: manifests
4961
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
50-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./cmd/... ./controllers/... ./sidecar/..." output:crd:artifacts:config=config/crd/bases
62+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="{./api/...,./cmd/...,./controllers/...,./sidecar/...}" output:crd:artifacts:config=config/crd/bases
5163

5264
.PHONY: bundle
5365
bundle: kustomize operator-sdk
54-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
55-
$(KUSTOMIZE) build config/default | $(OPERATOR_SDK) generate bundle --manifests --metadata --package=csi-addons --version=$(BUNDLE_VERSION)
66+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(CONTROLLER_IMG):$(TAG)
67+
$(KUSTOMIZE) build config/default | $(OPERATOR_SDK) generate bundle --manifests --metadata --package=$(PACKAGE_NAME) $(BUNDLE_VERSION)
5668
mkdir -p ./bundle/tests/scorecard && $(KUSTOMIZE) build config/scorecard --output=./bundle/tests/scorecard/config.yaml
5769

5870
.PHONY: generate
@@ -93,11 +105,11 @@ run: manifests generate fmt vet ## Run a controller from your host.
93105

94106
.PHONY: docker-build
95107
docker-build: test ## Build docker image with the manager.
96-
docker build -t ${IMG} .
108+
docker build -t ${CONTROLLER_IMG}:${TAG} .
97109

98110
.PHONY: docker-push
99111
docker-push: ## Push docker image with the manager.
100-
docker push ${IMG}
112+
docker push ${CONTROLLER_IMG}:${TAG}
101113

102114
.PHONY: docker-build-sidecar
103115
docker-build-sidecar:
@@ -131,7 +143,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
131143

132144
.PHONY: deploy
133145
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
134-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
146+
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG}:${TAG}
135147
$(KUSTOMIZE) build config/default | kubectl apply -f -
136148

137149
.PHONY: undeploy

PROJECT

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ resources:
2424
version: v1alpha1
2525
- api:
2626
crdVersion: v1
27-
namespaced: false
2827
controller: true
2928
domain: openshift.io
3029
group: csiaddons
3130
kind: NetworkFence
3231
path: github.com/csi-addons/kubernetes-csi-addons/api/v1alpha1
3332
version: v1alpha1
33+
- controller: true
34+
domain: openshift.io
35+
group: csiaddons
36+
kind: ReclaimSpaceCronJob
37+
version: v1alpha1
3438
version: "3"

api/v1alpha1/networkfence_types.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,12 @@ type NetworkFenceStatus struct {
7171

7272
//+kubebuilder:object:root=true
7373
//+kubebuilder:subresource:status
74-
7574
//+kubebuilder:printcolumn:name="Driver",type="string",JSONPath=".spec.driver"
7675
//+kubebuilder:printcolumn:name="Cidrs",type="string",JSONPath=".spec.cidrs"
7776
//+kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date
7877
//+kubebuilder:printcolumn:JSONPath=".status.result",name=Result,type=string
79-
80-
//+kubebuilder:object:root=true
81-
8278
//+kubebuilder:resource:path=networkfences,scope=Cluster,singular=networkfence
79+
8380
// NetworkFence is the Schema for the networkfences API
8481
type NetworkFence struct {
8582
metav1.TypeMeta `json:",inline"`
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/*
2+
Copyright 2022 The Kubernetes-CSI-Addons Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// ReclaimSpaceJobTemplateSpec describes the data a Job should have when created from a template
25+
type ReclaimSpaceJobTemplateSpec struct {
26+
// Standard object's metadata of the jobs created from this template.
27+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
28+
metav1.ObjectMeta `json:"metadata,omitempty"`
29+
30+
// Specification of the desired behavior of the job.
31+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
32+
// +kubebuilder:validation:Required
33+
Spec ReclaimSpaceJobSpec `json:"spec,omitempty"`
34+
}
35+
36+
// ReclaimSpaceCronJobSpec defines the desired state of ReclaimSpaceJob
37+
type ReclaimSpaceCronJobSpec struct {
38+
// The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
39+
// +kubebuilder:validation:Required
40+
// +kubebuilder:validation:Pattern:=.+
41+
Schedule string `json:"schedule"`
42+
43+
// Optional deadline in seconds for starting the job if it misses scheduled
44+
// time for any reason. Missed jobs executions will be counted as failed ones.
45+
// +kubebuilder:validation:Optional
46+
StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"`
47+
48+
// Specifies how to treat concurrent executions of a Job.
49+
// Valid values are:
50+
// - "Forbid" (default): forbids concurrent runs, skipping next run if
51+
// previous run hasn't finished yet;
52+
// - "Replace": cancels currently running job and replaces it
53+
// with a new one
54+
// +kubebuilder:validation:Optional
55+
// +kubebuilder:validation:Enum=Forbid;Replace
56+
// +kubebuilder:default:=Forbid
57+
ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"`
58+
59+
// This flag tells the controller to suspend subsequent executions, it does
60+
// not apply to already started executions. Defaults to false.
61+
// +kubebuilder:validation:Optional
62+
Suspend *bool `json:"suspend,omitempty"`
63+
64+
// Specifies the job that will be created when executing a CronJob.
65+
// +kubebuilder:validation:Required
66+
JobSpec ReclaimSpaceJobTemplateSpec `json:"jobTemplate"`
67+
68+
// The number of successful finished jobs to retain. Value must be non-negative integer.
69+
// Defaults to 3.
70+
// +kubebuilder:validation:Optional
71+
// +kubebuilder:validation:Maximum=60
72+
// +kubebuilder:validation:Minimum=0
73+
// +kubebuilder:default:=3
74+
SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"`
75+
76+
// The number of failed finished jobs to retain. Value must be non-negative integer.
77+
// Defaults to 1.
78+
// +kubebuilder:validation:Optional
79+
// +kubebuilder:validation:Maximum=60
80+
// +kubebuilder:validation:Minimum=0
81+
// +kubebuilder:default:=1
82+
FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"`
83+
}
84+
85+
// ConcurrencyPolicy describes how the job will be handled.
86+
// Only one of the following concurrent policies may be specified.
87+
// If none of the following policies is specified, the default one
88+
// is ReplaceConcurrent.
89+
type ConcurrencyPolicy string
90+
91+
const (
92+
// ForbidConcurrent forbids concurrent runs, skipping next run if previous
93+
// hasn't finished yet.
94+
ForbidConcurrent ConcurrencyPolicy = "Forbid"
95+
96+
// ReplaceConcurrent cancels currently running job and replaces it with a new one.
97+
ReplaceConcurrent ConcurrencyPolicy = "Replace"
98+
)
99+
100+
// ReclaimSpaceCronJobStatus defines the observed state of ReclaimSpaceJob
101+
type ReclaimSpaceCronJobStatus struct {
102+
// A pointer to currently running job.
103+
Active *v1.ObjectReference `json:"active,omitempty"`
104+
105+
// Information when was the last time the job was successfully scheduled.
106+
LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"`
107+
108+
// Information when was the last time the job successfully completed.
109+
LastSuccessfulTime *metav1.Time `json:"lastSuccessfulTime,omitempty"`
110+
}
111+
112+
//+kubebuilder:object:root=true
113+
//+kubebuilder:subresource:status
114+
//+kubebuilder:printcolumn:JSONPath=".spec.schedule",name=Schedule,type=string
115+
//+kubebuilder:printcolumn:JSONPath=".spec.suspend",name=Suspend,type=boolean
116+
//+kubebuilder:printcolumn:JSONPath=".status.active.name",name=Active,type=string
117+
//+kubebuilder:printcolumn:JSONPath=".status.lastScheduleTime",name=Lastschedule,type=date
118+
//+kubebuilder:printcolumn:JSONPath=".status.lastSuccessfulTime",name=Lastsuccessfultime,type=date,priority=1
119+
//+kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date
120+
121+
// ReclaimSpaceCronJob is the Schema for the reclaimspacecronjobs API
122+
type ReclaimSpaceCronJob struct {
123+
metav1.TypeMeta `json:",inline"`
124+
metav1.ObjectMeta `json:"metadata,omitempty"`
125+
126+
Spec ReclaimSpaceCronJobSpec `json:"spec,omitempty"`
127+
Status ReclaimSpaceCronJobStatus `json:"status,omitempty"`
128+
}
129+
130+
//+kubebuilder:object:root=true
131+
132+
// ReclaimSpaceCronJobList contains a list of ReclaimSpaceCronJob
133+
type ReclaimSpaceCronJobList struct {
134+
metav1.TypeMeta `json:",inline"`
135+
metav1.ListMeta `json:"metadata,omitempty"`
136+
Items []ReclaimSpaceCronJob `json:"items"`
137+
}
138+
139+
func init() {
140+
SchemeBuilder.Register(&ReclaimSpaceCronJob{}, &ReclaimSpaceCronJobList{})
141+
}

0 commit comments

Comments
 (0)