Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add jindo_runtime example #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Dockerfile.jindoruntime
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Build the jindoruntime-controller manager binary
FROM golang:1.14.2 as builder

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

RUN make jindoruntime-controller-build && \
cp bin/jindoruntime-controller /go/bin/jindoruntime-controller

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/jindofs /charts/jindo

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

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

7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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
JINDORUNTIME_CONTROLLER_IMG ?= registry.cn-hangzhou.aliyuncs.com/fluid/jindoruntime-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
Expand Down Expand Up @@ -59,6 +60,9 @@ dataset-controller-build: generate fmt vet
alluxioruntime-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="-N -l" -a -o bin/alluxioruntime-controller -ldflags '${LDFLAGS}' cmd/alluxio/main.go

jindoruntime-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="-N -l" -a -o bin/jindoruntime-controller -ldflags '${LDFLAGS}' cmd/jindo/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 Down Expand Up @@ -103,6 +107,9 @@ docker-build-dataset-controller: generate fmt vet
docker-build-alluxioruntime-controller: generate fmt vet
docker build --no-cache . -f Dockerfile.alluxioruntime -t ${ALLUXIORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

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

docker-build-csi: generate fmt vet
docker build --no-cache . -f Dockerfile.csi -t ${CSI_IMG}:${GIT_VERSION}

Expand Down
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ resources:
- group: data
kind: DataLoad
version: v1alpha1
- group: data
kind: JindoRuntime
version: v1alpha1
version: "2"
257 changes: 257 additions & 0 deletions api/v1alpha1/jindoruntime_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
/*

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"github.com/fluid-cloudnative/fluid/pkg/common"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// VersionSpec represents the settings for the Jindo version that fluid is orchestrating.
type JindoVersionSpec struct {
// Image for Jindo(e.g. jindo/jindo)
Image string `json:"image,omitempty"`

// Image tag for Jindo(e.g. 2.3.0-SNAPSHOT)
ImageTag string `json:"imageTag,omitempty"`

// One of the three policies: `Always`, `IfNotPresent`, `Never`
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
}

// AlluxioCompTemplateSpec is a description of the Alluxio commponents
type JindoCompTemplateSpec struct {
// Replicas is the desired number of replicas of the given template.
// If unspecified, defaults to 1.
// +kubebuilder:validation:Minimum=1
// replicas is the min replicas of dataset in the cluster
// +optional
Replicas int32 `json:"replicas,omitempty"`

// Options for JVM
JvmOptions []string `json:"jvmOptions,omitempty"`

// Configurable properties for the Alluxio component. <br>
// Refer to <a href="https://docs.alluxio.io/os/user/stable/en/reference/Properties-List.html">Alluxio Configuration Properties</a> for more info
// +optional
Properties map[string]string `json:"properties,omitempty"`

// Ports used by Alluxio(e.g. rpc: 19998 for master)
// +optional
Ports map[string]int `json:"ports,omitempty"`

// Resources that will be requested by the Alluxio component. <br>
// <br>
// Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources
// already allocated to the pod.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Environment variables that will be used by Alluxio component. <br>
Env map[string]string `json:"env,omitempty"`
}

// AlluxioFuseSpec is a description of the Alluxio Fuse
type JindoFuseSpec struct {

// Image for Alluxio Fuse(e.g. alluxio/alluxio-fuse)
Image string `json:"image,omitempty"`

// Image Tag for Alluxio Fuse(e.g. 2.3.0-SNAPSHOT)
ImageTag string `json:"imageTag,omitempty"`

// One of the three policies: `Always`, `IfNotPresent`, `Never`
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`

// Options for JVM
JvmOptions []string `json:"jvmOptions,omitempty"`

// Configurable properties for Alluxio System. <br>
// Refer to <a href="https://docs.alluxio.io/os/user/stable/en/reference/Properties-List.html">Alluxio Configuration Properties</a> for more info
Properties map[string]string `json:"properties,omitempty"`

// Environment variables that will be used by Alluxio Fuse
Env map[string]string `json:"env,omitempty"`

// ShortCircuitPolicy string `json:"shortCircuitPolicy,omitempty"`

// Resources that will be requested by Alluxio Fuse. <br>
// <br>
// Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources
// already allocated to the pod.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Arguments that will be passed to Alluxio Fuse
Args []string `json:"args,omitempty"`
}

// JindoRuntimeSpec defines the desired state of JindoRuntime
type JindoRuntimeSpec struct {
// The version information that instructs fluid to orchestrate a particular version of Alluxio.
JindoVersion JindoVersionSpec `json:"jindoVersion,omitempty"`

// Desired state for Alluxio master
Master JindoCompTemplateSpec `json:"master,omitempty"`

// Desired state for Alluxio job master
JobMaster JindoCompTemplateSpec `json:"jobMaster,omitempty"`

// Desired state for Alluxio worker
Worker JindoCompTemplateSpec `json:"worker,omitempty"`

// Desired state for Alluxio job Worker
JobWorker JindoCompTemplateSpec `json:"jobWorker,omitempty"`

// The spec of init users
InitUsers InitUsersSpec `json:"initUsers,omitempty"`

// Desired state for Alluxio Fuse
Fuse JindoFuseSpec `json:"fuse,omitempty"`

// Configurable properties for Alluxio system. <br>
// Refer to <a href="https://docs.alluxio.io/os/user/stable/en/reference/Properties-List.html">Alluxio Configuration Properties</a> for more info
Properties map[string]string `json:"properties,omitempty"`

// Options for JVM
JvmOptions []string `json:"jvmOptions,omitempty"`

// Tiered storage used by Alluxio
Tieredstore Tieredstore `json:"tieredstore,omitempty"`

// The replicas of the worker, need to be specified
Replicas int32 `json:"replicas,omitempty"`

// Manage the user to run Alluxio Runtime
RunAs *User `json:"runAs,omitempty"`
}

// JindoRuntimeStatus defines the observed state of JindoRuntime
type JindoRuntimeStatus struct {
// config map used to set configurations
ValueFileConfigmap string `json:"valueFile"`

// MasterPhase is the master running phase
MasterPhase RuntimePhase `json:"masterPhase"`

// Reason for Jindo Master's condition transition
MasterReason string `json:"masterReason,omitempty"`

// WorkerPhase is the worker running phase
WorkerPhase RuntimePhase `json:"workerPhase"`

// Reason for Jindo Worker's condition transition
WorkerReason string `json:"workerReason,omitempty"`

// The total number of nodes that should be running the runtime worker
// pod (including nodes correctly running the runtime worker pod).
DesiredWorkerNumberScheduled int32 `json:"desiredWorkerNumberScheduled"`

// The total number of nodes that can be running the runtime worker
// pod (including nodes correctly running the runtime worker pod).
CurrentWorkerNumberScheduled int32 `json:"currentWorkerNumberScheduled"`

// The number of nodes that should be running the runtime worker pod and have one
// or more of the runtime worker pod running and ready.
WorkerNumberReady int32 `json:"workerNumberReady"`

// The number of nodes that should be running the
// runtime worker pod and have one or more of the runtime worker pod running and
// available (ready for at least spec.minReadySeconds)
// +optional
WorkerNumberAvailable int32 `json:"workerNumberAvailable,omitempty"`

// The number of nodes that should be running the
// runtime worker pod and have none of the runtime worker pod running and available
// (ready for at least spec.minReadySeconds)
// +optional
WorkerNumberUnavailable int32 `json:"workerNumberUnavailable,omitempty"`

// The total number of nodes that should be running the runtime
// pod (including nodes correctly running the runtime master pod).
DesiredMasterNumberScheduled int32 `json:"desiredMasterNumberScheduled"`

// The total number of nodes that should be running the runtime
// pod (including nodes correctly running the runtime master pod).
CurrentMasterNumberScheduled int32 `json:"currentMasterNumberScheduled"`

// The number of nodes that should be running the runtime worker pod and have zero
// or more of the runtime master pod running and ready.
MasterNumberReady int32 `json:"masterNumberReady"`

// FusePhase is the Fuse running phase
FusePhase RuntimePhase `json:"fusePhase"`

// Reason for the condition's last transition.
FuseReason string `json:"fuseReason,omitempty"`

// The total number of nodes that can be running the runtime Fuse
// pod (including nodes correctly running the runtime Fuse pod).
CurrentFuseNumberScheduled int32 `json:"currentFuseNumberScheduled"`

// The total number of nodes that should be running the runtime Fuse
// pod (including nodes correctly running the runtime Fuse pod).
DesiredFuseNumberScheduled int32 `json:"desiredFuseNumberScheduled"`

// The number of nodes that should be running the runtime Fuse pod and have one
// or more of the runtime Fuse pod running and ready.
FuseNumberReady int32 `json:"fuseNumberReady"`

// The number of nodes that should be running the
// runtime fuse pod and have none of the runtime fuse pod running and available
// (ready for at least spec.minReadySeconds)
// +optional
FuseNumberUnavailable int32 `json:"fuseNumberUnavailable,omitempty"`

// The number of nodes that should be running the
// runtime Fuse pod and have one or more of the runtime Fuse pod running and
// available (ready for at least spec.minReadySeconds)
// +optional
FuseNumberAvailable int32 `json:"fuseNumberAvailable,omitempty"`

// Represents the latest available observations of a ddc runtime's current state.
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []RuntimeCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`

// CacheStatus represents the total resources of the dataset.
CacheStates common.CacheStateList `json:"cacheStates,omitempty"`
}

// +kubebuilder:object:root=true

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

Spec JindoRuntimeSpec `json:"spec,omitempty"`
Status JindoRuntimeStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// JindoRuntimeList contains a list of JindoRuntime
type JindoRuntimeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []JindoRuntime `json:"items"`
}

func init() {
SchemeBuilder.Register(&JindoRuntime{}, &JindoRuntimeList{})
}
Loading