Skip to content

Commit

Permalink
split dataset controller and alluxioruntime controller, edit makefile… (
Browse files Browse the repository at this point in the history
fluid-cloudnative#271)

* split dataset controller and alluxioruntime controller, edit makefile and dockerfile

* edit cmd of dockerfile,edit .travis.yaml, remove chart 0.4

Co-authored-by: 仇伶玮 <qiulingwei@gitlab.com>
  • Loading branch information
yangyuliufeng and 仇伶玮 authored Oct 27, 2020
1 parent 0d674aa commit 940d90b
Show file tree
Hide file tree
Showing 14 changed files with 425 additions and 128 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ matrix:
- sudo mv /tmp/kubebuilder_2.3.1_linux_${arch} /usr/local/kubebuilder
- export PATH=$PATH:/usr/local/kubebuilder/bin
script:
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -o bin/manager cmd/controller/main.go
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -o bin/dataset-controller cmd/dataset_controller/main.go
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -o bin/alluxioruntime-controller cmd/alluxioruntime_controller/main.go
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -o bin/csi cmd/csi/main.go
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go vet ./...
- golangci-lint run --timeout=10m ./...
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile.alluxioruntime
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Build the alluxioruntime-controller manager binary
FROM golang:1.14.2 as builder

WORKDIR /go/src/github.com/fluid-cloudnative/fluid
COPY . .

RUN make alluxioruntime-controller-build

FROM alpine:3.10
RUN apk add --update curl tzdata iproute2 bash libc6-compat vim && \
rm -rf /var/cache/apk/* && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone

RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/public/pkg/helm/helm-v3.0.3-linux-amd64.tar.gz && \
tar -xvf helm-v3.0.3-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ddc-helm && \
chmod u+x /usr/local/bin/ddc-helm && \
rm -f helm-v3.0.3-linux-amd64.tar.gz

ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

add charts/ /charts

COPY --from=builder /go/bin/alluxioruntime-controller /usr/local/bin/alluxioruntime-controller
RUN chmod -R u+x /usr/local/bin/

CMD ["alluxioruntime-controller", "start"]

14 changes: 4 additions & 10 deletions Dockerfile → Dockerfile.dataset
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# Build the manager binary
# Build the dataset-controller manager binary
FROM golang:1.14.2 as builder

WORKDIR /go/src/github.com/fluid-cloudnative/fluid
COPY . .

# Build
# RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="-N -l" -a -o /go/bin/fluid-controller cmd/controller/main.go

# Debug
#RUN go get github.com/go-delve/delve/cmd/dlv
RUN make dataset-controller-build

FROM alpine:3.10
RUN apk add --update curl tzdata iproute2 bash libc6-compat vim && \
Expand All @@ -28,9 +23,8 @@ RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-rel

add charts/ /charts

COPY --from=builder /go/bin/fluid-controller /usr/local/bin/fluid-controller
COPY --from=builder /go/bin/dataset-controller /usr/local/bin/dataset-controller
#COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
RUN chmod -R u+x /usr/local/bin/
CMD fluid-controller

# CMD ["dlv", "--listen=:12345", "exec", "/usr/local/bin/fluid-controller", "--", "--enable-leader-election"]
CMD ["dataset-controller", "start"]
33 changes: 23 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ IMG ?= registry.cn-hangzhou.aliyuncs.com/fluid/runtime-controller
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"

# The Image URL to use in docker build and push
DATASET_CONTROLLER_IMG ?= registry.cn-hangzhou.aliyuncs.com/fluid/dataset-controller
ALLUXIORUNTIME_CONTROLLER_IMG ?= registry.cn-hangzhou.aliyuncs.com/fluid/alluxioruntime-controller
CSI_IMG ?= registry.cn-hangzhou.aliyuncs.com/fluid/fluid-csi

LOADER_IMG ?= registry.cn-hangzhou.aliyuncs.com/fluid/fluid-dataloader

INIT_USERS_IMG ?= registry.cn-hangzhou.aliyuncs.com/fluid/init-users

LOCAL_FLAGS ?= -gcflags=-l
Expand Down Expand Up @@ -54,10 +55,16 @@ manager: generate fmt vet
csi: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -o bin/csi -ldflags '${LDFLAGS}' cmd/csi/main.go

# Build CSI binary in dockerfile
# Build binary in docker images, will be called in Dockerfile
csi-build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -o /go/bin/fluid-csi -ldflags '${LDFLAGS}' cmd/csi/main.go

dataset-controller-build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="-N -l" -a -o /go/bin/dataset-controller -ldflags '${LDFLAGS}' cmd/dataset_controller/main.go

alluxioruntime-controller-build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="-N -l" -a -o /go/bin/alluxioruntime-controller -ldflags '${LDFLAGS}' cmd/alluxioruntime_controller/main.go

# Debug against the configured Kubernetes cluster in ~/.kube/config, add debug
debug: generate fmt vet manifests
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off dlv debug --headless --listen ":12345" --log --api-version=2 cmd/controller/main.go
Expand All @@ -83,7 +90,7 @@ deploy: manifests
manifests: controller-gen
GO111MODULE=off $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases

# Run go fmt against code
# Run go fmt against codecsi-node-driver-registrar
fmt:
GO111MODULE=off go fmt ./...

Expand All @@ -96,8 +103,11 @@ generate: controller-gen
GO111MODULE=off $(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."

# Build the docker image
docker-build: generate fmt vet
docker build --no-cache . -t ${IMG}:${GIT_VERSION}
docker-build-dataset-controller: generate fmt vet
docker build --no-cache . -f Dockerfile.dataset -t ${DATASET_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-alluxioruntime-controller: generate fmt vet
docker build --no-cache . -f Dockerfile.alluxioruntime -t ${ALLUXIORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-csi: generate fmt vet
docker build --no-cache . -f Dockerfile.csi -t ${CSI_IMG}:${GIT_VERSION}
Expand All @@ -109,8 +119,11 @@ docker-build-init-users:
docker build --no-cache charts/alluxio/docker/init-users -t ${INIT_USERS_IMG}:${GIT_VERSION}

# Push the docker image
docker-push: docker-build
docker push ${IMG}:${GIT_VERSION}
docker-push-dataset-controller: docker-build-dataset-controller
docker push ${DATASET_CONTROLLER_IMG}:${GIT_VERSION}

docker-push-alluxioruntime-controller: docker-build-alluxioruntime-controller
docker push ${ALLUXIORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-push-csi: docker-build-csi
docker push ${CSI_IMG}:${GIT_VERSION}
Expand All @@ -121,8 +134,8 @@ docker-push-loader: docker-build-loader
docker-push-init-users: docker-build-init-users
docker push ${INIT_USERS_IMG}:${GIT_VERSION}

docker-push-all: docker-push-init-users docker-push docker-push-csi
docker-build-all: docker-build-init-users docker-build docker-build-csi
docker-build-all: docker-build-dataset-controller docker-build-alluxioruntime-controller docker-build-csi docker-build-init-users
docker-push-all: docker-push-dataset-controller docker-push-alluxioruntime-controller docker-push-csi docker-push-init-users

# find or download controller-gen
# download controller-gen if necessary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,32 @@
# apiVersion: v1
# kind: Namespace
# metadata:
# labels:
# control-plane: controller-manager
# name: fluid-system

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
name: alluxioruntime-controller-manager
namespace: fluid-system
labels:
control-plane: controller-manager
control-plane: alluxioruntime-controller-manager
spec:
selector:
matchLabels:
control-plane: controller-manager
control-plane: alluxioruntime-controller-manager
replicas: 1
template:
metadata:
labels:
control-plane: controller-manager
control-plane: alluxioruntime-controller-manager
spec:
serviceAccountName: fluid
serviceAccountName: alluxioruntime-controller
tolerations:
- operator: Exists
hostNetwork: true
containers:
- command:
- fluid-controller
# args:
# - --enable-leader-election
image: "{{ .Values.controller.image }}"
- image: "{{ .Values.runtime.alluxio.image }}"
name: manager
command:
- fluid-controller
command: ["alluxioruntime-controller", "start"]
args:
- --development=false
# args:
# - --capacity-percentage={{ .Values.controller.capacityPercentagePerNode }}
# - --reserved={{ .Values.controller.reservedStorage }}
# - --cache-store-type={{ .Values.controller.cacheStoreType }}
# - --cache-storage-path={{ .Values.controller.cacheStoragePath }}
env:
{{- if .Values.runtime.alluxio.initImage }}
- name: ALLUXIO_INIT_IMAGE_ENV
Expand All @@ -62,8 +47,4 @@ spec:
requests:
cpu: 100m
memory: 200Mi
ports:
- containerPort: 8080
name: metrics
protocol: TCP
terminationGracePeriodSeconds: 10
51 changes: 51 additions & 0 deletions charts/fluid/fluid/templates/manager/dataset_controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# apiVersion: v1
# kind: Namespace
# metadata:
# labels:
# control-plane: controller-manager
# name: fluid-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: dataset-controller-manager
namespace: fluid-system
labels:
control-plane: dataset-controller-manager
spec:
selector:
matchLabels:
control-plane: dataset-controller-manager
replicas: 1
template:
metadata:
labels:
control-plane: dataset-controller-manager
spec:
serviceAccountName: dataset-controller
tolerations:
- operator: Exists
hostNetwork: true
containers:
- image: "{{ .Values.dataset.controller.image }}"
name: manager
command: ["dataset-controller", "start"]
args:
- --development=false
env:
{{- if .Values.runtime.alluxio.initImage }}
- name: ALLUXIO_INIT_IMAGE_ENV
value: {{ .Values.runtime.alluxio.initImage | quote }}
{{- end }}
ports:
- containerPort: 8080
name: metrics
protocol: TCP
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 200Mi
terminationGracePeriodSeconds: 10
61 changes: 61 additions & 0 deletions charts/fluid/fluid/templates/role/ClusterRole
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dataset-manager
rules:
- apiGroups:
- data.fluid.io
resources:
- datasets
- datasets/status
verbs:
- '*'
- apiGroups:
- ""
resources:
- events
verbs:
- '*'
---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: alluxioruntime-manager
rules:
- apiGroups:
- ""
resources:
- persistentvolumeclaims
- persistentvolumes
- services
- endpoints
- configmaps
- events
- namespaces
- pods
- pods/exec
- secrets
- nodes
verbs:
- '*'
- apiGroups:
- data.fluid.io
resources:
- alluxiodataloads
- alluxioruntimes
- datasets
- alluxiodataloads/status
- alluxioruntimes/status
- datasets/status
verbs:
- '*'
- apiGroups:
- apps
resources:
- daemonsets
- statefulsets
- daemonsets/status
- statefulsets/status
verbs:
- '*'
27 changes: 27 additions & 0 deletions charts/fluid/fluid/templates/role/ClusterRoleBindind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dataset-clusterrolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: dataset-manager
subjects:
- kind: ServiceAccount
name: dataset-controller
namespace: fluid-system

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: alluxioruntime-clusterrolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: alluxioruntime-manager
subjects:
- kind: ServiceAccount
name: alluxioruntime-controller
namespace: fluid-system
13 changes: 13 additions & 0 deletions charts/fluid/fluid/templates/role/ServiceAccount
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: dataset-controller
namespace: fluid-system

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: alluxioruntime-controller
namespace: fluid-system
19 changes: 0 additions & 19 deletions charts/fluid/fluid/templates/role/role-binding.yaml

This file was deleted.

Loading

0 comments on commit 940d90b

Please sign in to comment.