Skip to content

Commit

Permalink
Merge release v0.1.12
Browse files Browse the repository at this point in the history
Release v0.1.12
  • Loading branch information
roehrich-hpe authored Dec 9, 2024
2 parents 5f7daaa + 94856e4 commit 28fb586
Show file tree
Hide file tree
Showing 88 changed files with 3,269 additions and 1,138 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ jobs:
- name: "Verify auto-generated files"
run: |
make manifests generate
git status
if [[ $(git status -s | wc -l) -gt 0 ]]; then \
git status; exit 1; \
exit 1; \
fi
- name: "Docker metadata"
Expand Down
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
"--socket=/tmp/nnf.sock"
]
},
{
"name": "Debug Copy-Offload server",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/daemons/copy-offload/cmd",
"env": {"NNF_NODE_NAME": "rabbit-node-1"},
"args" :[
"--port=8080",
"--mock",
]
},
{
"name": "Launch file",
"type": "go",
Expand Down
51 changes: 46 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
# These ARGs must be before the first FROM. This allows them to be valid for
# use in FROM instructions.
ARG NNFMFU_TAG_BASE=ghcr.io/nearnodeflash/nnf-mfu
ARG NNFMFU_VERSION=0.1.3
ARG NNFMFU_VERSION=0.1.4

# Build the manager binary
FROM golang:1.21-alpine AS builder

ARG TARGETARCH
ARG TARGETOS
FROM golang:1.21-alpine AS builder_setup

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -40,16 +37,39 @@ COPY cmd/ cmd/
COPY api/ api/
COPY internal/ internal/

###############################################################################
FROM builder_setup AS builder

ARG TARGETARCH
ARG TARGETOS

# Build
# the GOARCH has a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

###############################################################################
FROM builder_setup AS copy_offload_builder

ARG TARGETARCH
ARG TARGETOS

COPY daemons/copy-offload/ daemons/copy-offload/

# Build
# the GOARCH has a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o nnf-copy-offload daemons/copy-offload/cmd/main.go

###############################################################################
FROM builder AS testing

COPY daemons/copy-offload/ daemons/copy-offload/

WORKDIR /workspace

COPY config/ config/
Expand Down Expand Up @@ -102,3 +122,24 @@ ENTRYPOINT ["/manager"]
ARG NNFMFU_TAG_BASE
ARG NNFMFU_VERSION
LABEL nnf-mfu="$NNFMFU_TAG_BASE-debug:$NNFMFU_VERSION"

###############################################################################
FROM $NNFMFU_TAG_BASE:$NNFMFU_VERSION AS copy_offload_production

# The following lines are from the mpiFileUtils (nnf-mfu) Dockerfile;
# do not change them unless you know what it is you are doing
RUN sed -i "s/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g" /etc/ssh/ssh_config \
&& echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config

# Copy the executable and execute
WORKDIR /
COPY --from=copy_offload_builder /workspace/nnf-copy-offload .

ENTRYPOINT ["/nnf-copy-offload"]

# Make it easy to figure out which nnf-mfu was used.
# docker inspect --format='{{json .Config.Labels}}' image:tag
ARG NNFMFU_TAG_BASE
ARG NNFMFU_VERSION
LABEL nnf-mfu="$NNFMFU_TAG_BASE:$NNFMFU_VERSION"

54 changes: 45 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# cray.hpe.com/nnf-dm-bundle:$VERSION and cray.hpe.com/nnf-dm-catalog:$VERSION.
IMAGE_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-dm
IMAGE_COPY_OFFLOAD_TAG_BASE = $(IMAGE_TAG_BASE)-copy-offload
IMAGE_TARGET ?= production
IMAGE_COPY_OFFLOAD_TARGET = copy_offload_$(IMAGE_TARGET)

# The NNF-MFU container image to use in NNFContainerProfile resources.
NNFMFU_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-mfu
NNFMFU_VERSION ?= 0.1.3
NNFMFU_VERSION ?= 0.1.4

CONTAINER_BUILDARGS=--build-arg NNFMFU_TAG_BASE=$(NNFMFU_TAG_BASE) --build-arg NNFMFU_VERSION=$(NNFMFU_VERSION)

Expand All @@ -62,6 +64,16 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.0

# Tell Kustomize to deploy the default config, or an overlay.
# To use the 'craystack' overlay:
# export KUBECONFIG=/my/craystack/kubeconfig.file
# make deploy OVERLAY=craystack
#
# To use the 'dp0' overlay:
# export KUBECONFIG=/my/dp0/kubeconfig.file
# make deploy OVERLAY=dp0
OVERLAY ?= kind

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -126,7 +138,7 @@ container-unit-test: .version ## Run tests inside a container image
${CONTAINER_TOOL} build -f Dockerfile --label $(IMAGE_TAG_BASE)-$@:$(VERSION)-$@ -t $(IMAGE_TAG_BASE)-$@:$(VERSION) --target testing $(CONTAINER_BUILDARGS) .
${CONTAINER_TOOL} run --rm -t --name $@-nnf-dm $(IMAGE_TAG_BASE)-$@:$(VERSION)

##@ Build
##@ Build the controller manager.
RPM_PLATFORM ?= linux/amd64
RPM_TARGET ?= x86_64
.PHONY: build-daemon-rpm
Expand Down Expand Up @@ -158,6 +170,35 @@ build: generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
CGO_ENABLED=0 go run cmd/main.go

##@ Build the copy-offload container's daemon outside the container.
.PHONY: build-copy-offload-local
build-copy-offload-local: GOOS = $(shell go env GOOS)
build-copy-offload-local: GOARCH = $(shell go env GOARCH)
build-copy-offload-local: build-copy-offload-with

.PHONY: build-copy-offload-with
build-copy-offload-with: $(LOCALBIN)
build-copy-offload-with: fmt vet ## Build standalone copy-offload daemon
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/nnf-copy-offload daemons/copy-offload/cmd/main.go

.PHONY: build-copy-offload-docker-local
build-copy-offload-docker-local: GOARCH = $(shell go env GOARCH)
build-copy-offload-docker-local: build-copy-offload-docker-with

.PHONY: build-copy-offload-docker-amd64
build-copy-offload-docker-amd64: GOARCH = amd64
build-copy-offload-docker-amd64: build-copy-offload-docker-with

.PHONY: build-copy-offload-docker-with
build-copy-offload-docker-with: VERSION ?= $(shell cat .version)
build-copy-offload-docker-with: .version ## Build docker image with the manager.
${CONTAINER_TOOL} build --platform linux/$(GOARCH) --target $(IMAGE_COPY_OFFLOAD_TARGET) -t $(IMAGE_COPY_OFFLOAD_TAG_BASE):$(VERSION) $(CONTAINER_BUILDARGS) .

.PHONY: kind-push-copy-offload
kind-push-copy-offload: VERSION ?= $(shell cat .version)
kind-push-copy-offload: .version
kind load docker-image $(IMAGE_COPY_OFFLOAD_TAG_BASE):$(VERSION)

# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
Expand Down Expand Up @@ -205,12 +246,7 @@ docker-buildx-debug: docker-buildx

kind-push: VERSION ?= $(shell cat .version)
kind-push: .version ## Push docker image to kind
# Nnf-dm is used on all nodes. It's on the management node for the
# nnf-dm-controller-manager deployment, and on the rabbit nodes for
# the nnf-dm-rsyncnode daemonset that is created by that deployment.
kind load docker-image $(IMAGE_TAG_BASE):$(VERSION)
${CONTAINER_TOOL} pull gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
kind load docker-image gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0

kind-push-debug: VERSION ?= $(shell cat .version)
kind-push-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
Expand All @@ -224,13 +260,13 @@ minikube-push: .version

edit-image: VERSION ?= $(shell cat .version)
edit-image: .version
$(KUSTOMIZE_IMAGE_TAG) config/begin default $(IMAGE_TAG_BASE) $(VERSION) $(NNFMFU_TAG_BASE) $(NNFMFU_VERSION)
$(KUSTOMIZE_IMAGE_TAG) config/begin $(OVERLAY) $(IMAGE_TAG_BASE) $(VERSION) $(NNFMFU_TAG_BASE) $(NNFMFU_VERSION)

deploy: kustomize edit-image ## Deploy controller to the K8s cluster specified in ~/.kube/config.
./deploy.sh deploy $(KUSTOMIZE) config/begin

undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
./deploy.sh undeploy $(KUSTOMIZE) config/default
./deploy.sh undeploy $(KUSTOMIZE) config/$(OVERLAY)

# Let .version be phony so that a git update to the workarea can be reflected
# in it each time it's needed.
Expand Down
16 changes: 8 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

lusv1beta1 "github.com/NearNodeFlash/lustre-fs-operator/api/v1beta1"
nnfv1alpha3 "github.com/NearNodeFlash/nnf-sos/api/v1alpha3"
nnfv1alpha4 "github.com/NearNodeFlash/nnf-sos/api/v1alpha4"

controllers "github.com/NearNodeFlash/nnf-dm/internal/controller"
//+kubebuilder:scaffold:imports
Expand All @@ -57,7 +57,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(lusv1beta1.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha3.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha4.AddToScheme(scheme))

//+kubebuilder:scaffold:scheme
}
Expand Down Expand Up @@ -177,7 +177,7 @@ func (*managerController) GetType() string { return ManagerController }
func (*managerController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementNamespace] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}

Expand All @@ -200,16 +200,16 @@ func (*defaultController) GetType() string { return DefaultController }
func (*defaultController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementProfileNamespace] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}

func (c *defaultController) SetupReconcilers(mgr manager.Manager) (err error) {
if err = (&controllers.DataMovementReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
WatchNamespace: nnfv1alpha3.DataMovementNamespace,
WatchNamespace: nnfv1alpha4.DataMovementNamespace,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", c.GetType())
os.Exit(1)
Expand All @@ -227,8 +227,8 @@ func (*nodeController) GetType() string { return NodeController }
func (*nodeController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[os.Getenv("NNF_NODE_NAME")] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}
Expand Down
62 changes: 62 additions & 0 deletions config/copy-offload/copy_offload_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: copy-offload-role
rules:
- apiGroups:
- lus.cray.hpe.com
resources:
- lustrefilesystems
verbs:
- get
- list
- watch
- apiGroups:
- dataworkflowservices.github.io
resources:
- workflows
verbs:
- get
- list
- watch
- apiGroups:
- dataworkflowservices.github.io
resources:
- clientmounts
verbs:
- get
- list
- watch
- apiGroups:
- nnf.cray.hpe.com
resources:
- nnfdatamovementprofiles
verbs:
- get
- list
- watch
- apiGroups:
- nnf.cray.hpe.com
resources:
- nnfnodes
verbs:
- get
- list
- watch
- apiGroups:
- nnf.cray.hpe.com
resources:
- nnfnodestorages
verbs:
- get
- list
- watch
- apiGroups:
- nnf.cray.hpe.com
resources:
- nnfstorages
verbs:
- get
- list
- watch
12 changes: 12 additions & 0 deletions config/copy-offload/copy_offload_role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: copy-offload-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: copy-offload-role
subjects:
- kind: ServiceAccount
name: copy-offload
namespace: default
18 changes: 18 additions & 0 deletions config/copy-offload/copy_offload_service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: copy-offload
namespace: default
---
# As of Kubernetes 1.24, ServiceAccount tokens are no longer automatically
# generated. Instead, manually create the secret and the token key in the
# data field will be automatically set.
apiVersion: v1
kind: Secret
metadata:
name: copy-offload
namespace: default
annotations:
kubernetes.io/service-account.name: copy-offload
kubernetes.io/service-account.namespace: default
type: kubernetes.io/service-account-token
14 changes: 14 additions & 0 deletions config/copy-offload/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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: nnf-dm-

resources:
- copy_offload_service_account.yaml
- copy_offload_role.yaml
- copy_offload_role_binding.yaml

configurations:
- kustomizeconfig.yaml
4 changes: 4 additions & 0 deletions config/copy-offload/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namePrefix:
- path: metadata/annotations/kubernetes.io\/service-account.name
namespace:
- path: metadata/annotations/kubernetes.io\/service-account.namespace
6 changes: 6 additions & 0 deletions config/dp0/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- ../top

patches:
# Arguments for the controller manager that are specific to dp0
- path: manager_environment_deploy_patch.yaml
Loading

0 comments on commit 28fb586

Please sign in to comment.