Skip to content

Commit

Permalink
Merge pull request ceph#14 from ceph/main
Browse files Browse the repository at this point in the history
SYNC DS branch with US
  • Loading branch information
nb-ohad authored Aug 13, 2024
2 parents 982cabd + 30dc30d commit e5e648b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 28 deletions.
64 changes: 53 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ REGISTRY_NAMESPACE ?= cephcsi
IMAGE_TAG ?= latest
IMAGE_NAME ?= ceph-csi-operator

# Use different name prefix and namespace prefix for csi rbac kustomize
CSI_RBAC_NAME_PREFIX ?= ceph-csi-operator-
CSI_RBAC_NAMESPACE ?= $(CSI_RBAC_NAME_PREFIX)system
# Allow customization of the name prefix and/or namespace
NAME_PREFIX ?= ceph-csi-operator-
NAMESPACE ?= $(NAME_PREFIX)system

IMG ?= $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/$(IMAGE_NAME):$(IMAGE_TAG)

Expand All @@ -31,6 +31,44 @@ CONTAINER_TOOL ?= docker
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

# Define the content of the temporary top-most kustomize overlay for the
# build-installer and deploy targets
define BUILD_INSTALLER_OVERLAY
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: $(NAMESPACE)
namePrefix: $(NAME_PREFIX)
patches:
- patch: |-
- op: add
path: /spec/template/spec/containers/1/env/-
value:
name: CSI_SERVICE_ACCOUNT_PREFIX
value: $(NAME_PREFIX)
target:
kind: Deployment
name: controller-manager
images:
- name: controller
newName: ${IMG}
resources:
- ../config/default
endef
export BUILD_INSTALLER_OVERLAY


# Define the content of the temporary top-most kustomize overlay for the
# build-csi-rbac target
define BUILD_CSI_RBAC_OVERLAY
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: $(NAMESPACE)
namePrefix: $(NAME_PREFIX)
resources:
- ../config/csi-rbac
endef
export BUILD_CSI_RBAC_OVERLAY

.PHONY: all
all: build

Expand Down Expand Up @@ -126,15 +164,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform

.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p dist
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > dist/install.yaml
mkdir -p build dist
cd build && echo "$$BUILD_INSTALLER_OVERLAY" > kustomization.yaml
$(KUSTOMIZE) build build > dist/install.yaml
rm -rf build

.PHONY: build-csi-rbac
build-csi-rbac:
cd config/csi-rbac && $(KUSTOMIZE) edit set nameprefix $(CSI_RBAC_NAME_PREFIX)
cd config/csi-rbac && $(KUSTOMIZE) edit set namespace $(CSI_RBAC_NAMESPACE)
$(KUSTOMIZE) build config/csi-rbac > dist/csi-rbac.yaml
mkdir -p build dist
cd build && echo "$$BUILD_CSI_RBAC_OVERLAY" > kustomization.yaml
$(KUSTOMIZE) build build > dist/csi-rbac.yaml
rm -rf build
##@ Deployment

ifndef ignore-not-found
Expand All @@ -151,8 +191,10 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
mkdir -p build
cd build && echo "$$BUILD_INSTALLER_OVERLAY" > kustomization.yaml
$(KUSTOMIZE) build build | $(KUBECTL) apply -f -
rm -rf build

.PHONY: undeploy
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
Expand Down
10 changes: 0 additions & 10 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# Adds namespace to all resources.
namespace: ceph-csi-operator-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: ceph-csi-operator-

# Labels to add to all resources and selectors.
#labels:
#- includeSelectors: true
Expand Down
4 changes: 0 additions & 4 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ resources:
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: quay.io/cephcsi/ceph-csi-operator
newTag: latest
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
- /manager
args:
- --leader-elect
image: controller:latest
image: controller
name: manager
securityContext:
allowPrivilegeEscalation: false
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ var operatorConfigName = utils.Call(func() string {
}
return "ceph-csi-operator-config"
})

var serviceAccountPrefix = utils.Call(func() string {
return os.Getenv("CSI_SERVICE_ACCOUNT_PREFIX")
})
4 changes: 2 additions & 2 deletions internal/controller/driver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (r *driverReconcile) reconcileControllerPluginDeployment() error {
pluginSpec := cmp.Or(r.driver.Spec.ControllerPlugin, &csiv1a1.ControllerPluginSpec{})
serviceAccountName := cmp.Or(
ptr.Deref(pluginSpec.ServiceAccountName, ""),
fmt.Sprintf("csi-%s-ctrlplugin-sa", r.driverType),
fmt.Sprintf("%s%s-ctrlplugin-sa", serviceAccountPrefix, r.driverType),
)
imagePullPolicy := cmp.Or(pluginSpec.ImagePullPolicy, corev1.PullIfNotPresent)
grpcTimeout := cmp.Or(r.driver.Spec.GRpcTimeout, defaultGRrpcTimeout)
Expand Down Expand Up @@ -798,7 +798,7 @@ func (r *driverReconcile) reconcileNodePluginDeamonSet() error {
pluginSpec := cmp.Or(r.driver.Spec.NodePlugin, &csiv1a1.NodePluginSpec{})
serviceAccountName := cmp.Or(
ptr.Deref(pluginSpec.ServiceAccountName, ""),
fmt.Sprintf("csi-%s-nodeplugin-sa", r.driverType),
fmt.Sprintf("%s%s-nodeplugin-sa", serviceAccountPrefix, r.driverType),
)
imagePullPolicy := cmp.Or(pluginSpec.ImagePullPolicy, corev1.PullIfNotPresent)
logVerbosity := ptr.Deref(r.driver.Spec.Log, csiv1a1.LogSpec{}).Verbosity
Expand Down

0 comments on commit e5e648b

Please sign in to comment.