Skip to content

Commit

Permalink
support alluxio container network
Browse files Browse the repository at this point in the history
Signed-off-by: mahao <[email protected]>
  • Loading branch information
allenhaozi committed Dec 19, 2021
1 parent 6798047 commit 9729a91
Show file tree
Hide file tree
Showing 37 changed files with 1,007 additions and 639 deletions.
14 changes: 12 additions & 2 deletions api/v1alpha1/alluxioruntime_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
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
Expand All @@ -16,10 +15,11 @@ limitations under the License.
package v1alpha1

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

"github.com/fluid-cloudnative/fluid/pkg/common"
)

type AlluxioRuntimeRole common.RuntimeRole
Expand Down Expand Up @@ -76,6 +76,11 @@ type AlluxioCompTemplateSpec struct {
// NodeSelector is a selector which must be true for the master to fit on a node
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// Whether to use hostnetwork or not
// +kubebuilder:validation:Enum=HostNetwork;"";ContainerNetwork
// +optional
NetworkMode NetworkMode `json:"networkMode,omitempty"`
}

// AlluxioFuseSpec is a description of the Alluxio Fuse
Expand Down Expand Up @@ -121,6 +126,11 @@ type AlluxioFuseSpec struct {
// this option only effect when global is enabled
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// Whether to use hostnetwork or not
// +kubebuilder:validation:Enum=HostNetwork;"";ContainerNetwork
// +optional
NetworkMode NetworkMode `json:"networkMode,omitempty"`
}

// Level describes configurations a tier needs. <br>
Expand Down
11 changes: 0 additions & 11 deletions api/v1alpha1/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,3 @@ const (
// DefaultMode is exclusive
DefaultMode PlacementMode = ""
)

type NetworkMode string

const (
HostNetworkMode NetworkMode = "HostNetwork"

ContainerNetworkMode NetworkMode = "ContainerNetwork"

// DefaultMode is Host
DefaultNetworkMode NetworkMode = ""
)
34 changes: 34 additions & 0 deletions api/v1alpha1/container_network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
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

type NetworkMode string

const (
HostNetworkMode NetworkMode = "HostNetwork"

ContainerNetworkMode NetworkMode = "ContainerNetwork"

// DefaultMode is Host
DefaultNetworkMode NetworkMode = ""
)

func IsHostNetwork(n NetworkMode) bool {
switch n {
case ContainerNetworkMode:
return false
default:
return true
}
}
43 changes: 43 additions & 0 deletions api/v1alpha1/container_network_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
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 "testing"

func TestIsHostNetwork(t *testing.T) {
testCases := map[string]struct {
n NetworkMode
want bool
}{
"test host network case 1": {
n: HostNetworkMode,
want: true,
},
"test host network case 2": {
n: "",
want: true,
},
"test container network case 1": {
n: ContainerNetworkMode,
want: false,
},
}

for k, v := range testCases {
got := IsHostNetwork(v.n)
if v.want != got {
t.Errorf("check %s failure, got:%t,want:%t", k, got, v.want)
}
}
}
5 changes: 3 additions & 2 deletions charts/alluxio/templates/fuse/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{{ if .Values.fuse.enabled -}}
{{- $shortCircuitEnabled := .Values.shortCircuit.enabled -}}
{{- $needDomainSocketVolume := and $shortCircuitEnabled (eq .Values.shortCircuit.policy "uuid") }}
{{- $fuseHostNetwork := .Values.fuse.hostNetwork }}

apiVersion: apps/v1
kind: DaemonSet
Expand Down Expand Up @@ -44,9 +45,9 @@ spec:
priorityClassName: system-node-critical
{{- end }}
enableServiceLinks: false
hostNetwork: {{ .Values.fuse.hostNetwork }}
hostNetwork: {{ $fuseHostNetwork }}
hostPID: {{ .Values.fuse.hostPID }}
dnsPolicy: {{ .Values.fuse.dnsPolicy }}
dnsPolicy: {{ .Values.fuse.dnsPolicy | default ($fuseHostNetwork | ternary "ClusterFirst" "ClusterFirst") }}
nodeSelector:
{{- if .Values.fuse.nodeSelector }}
{{ toYaml .Values.fuse.nodeSelector | trim | indent 8 }}
Expand Down
78 changes: 37 additions & 41 deletions charts/alluxio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# This should not be modified in the usual case.
fullnameOverride: alluxio


## Common ##

# Docker Image
Expand All @@ -22,7 +21,7 @@ imagePullPolicy: IfNotPresent

# Create User Docker Image // TODO make it configurable
initUsers:
enabled: false
enabled: false
image: registry.cn-hangzhou.aliyuncs.com/fluid/init-users
imageTag: v0.3.0-1467caa
imagePullPolicy: IfNotPresent
Expand Down Expand Up @@ -87,11 +86,11 @@ master:
resources:
# The default xmx is 8G
limits:
# cpu: "4"
# memory: "8G"
# cpu: "4"
# memory: "8G"
requests:
# cpu: "1"
# memory: "1G"
# cpu: "1"
# memory: "1G"
ports:
embedded: 19200
rpc: 19998
Expand Down Expand Up @@ -120,11 +119,11 @@ jobMaster:
properties:
resources:
limits:
# cpu: "4"
# memory: "8G"
# cpu: "4"
# memory: "8G"
requests:
# cpu: "1"
# memory: "1G"
# cpu: "1"
# memory: "1G"
ports:
embedded: 20003
rpc: 20001
Expand All @@ -144,8 +143,8 @@ jobMaster:
journal:
# Setting journal type, "UFS" or "EMBEDDED"
# In commit 2c125dee25f8d4566ae23646a999c16c530ffbc9, in order to support master raft embeeded journal mode, change default value from UFS to EMBEDDED
# TODO (@xieydd), will support journalClaimTemplates configure the journal setting
type: "EMBEDDED"
# TODO (@xieydd), will support journalClaimTemplates configure the journal setting
type: "EMBEDDED"
ufsType: "local" # Ignored if type is "EMBEDDED". "local" or "HDFS"
folder: "/journal" # Master journal folder
# volumeType controls the type of journal volume.
Expand All @@ -169,15 +168,14 @@ apiGateway:
properties:
resources:
limits:
# cpu: "4"
# memory: "4G"
# cpu: "4"
# memory: "4G"
requests:
# cpu: "1"
# memory: "2G"
# cpu: "1"
# memory: "2G"
ports:
rest: 39999


# You can enable metastore to use ROCKS DB instead of Heap
# metastore:
# volumeType: persistentVolumeClaim # Options: "persistentVolumeClaim" or "emptyDir"
Expand All @@ -190,26 +188,25 @@ apiGateway:
# # Attributes to use when the metastore is emptyDir
# medium: ""


## Worker ##

worker:
env:
# Extra environment variables for the worker pod
# Example:
# JAVA_HOME: /opt/java
# Extra environment variables for the worker pod
# Example:
# JAVA_HOME: /opt/java
args:
- worker-only
- --no-format
# Properties for the worker component
properties:
resources:
limits:
# cpu: "4"
# memory: "4G"
# cpu: "4"
# memory: "4G"
requests:
# cpu: "1"
# memory: "2G"
# cpu: "1"
# memory: "2G"
ports:
rpc: 29999
web: 30000
Expand All @@ -232,11 +229,11 @@ jobWorker:
properties:
resources:
limits:
# cpu: "4"
# memory: "4G"
# cpu: "4"
# memory: "4G"
requests:
# cpu: "1"
# memory: "1G"
# cpu: "1"
# memory: "1G"
ports:
rpc: 30001
data: 30002
Expand Down Expand Up @@ -280,14 +277,14 @@ jobWorker:
# quota: 10G,10G
tieredstore:
levels:
- level: 0
alias: MEM
mediumtype: MEM
path: /dev/shm
type: emptyDir
quota: 1G
high: 0.95
low: 0.7
- level: 0
alias: MEM
mediumtype: MEM
path: /dev/shm
type: emptyDir
quota: 1G
high: 0.95
low: 0.7

# Short circuit related properties
shortCircuit:
Expand All @@ -308,7 +305,6 @@ shortCircuit:
# Attributes to use if the domain socket volume is hostPath
hostPath: "/tmp/alluxio-domain" # The hostPath directory to use


## FUSE ##

fuse:
Expand Down Expand Up @@ -336,7 +332,7 @@ fuse:
hostNetwork: true
# hostPID requires escalated privileges
hostPID: true
dnsPolicy: ClusterFirstWithHostNet
dnsPolicy: ""
user: 0
group: 0
fsGroup: 0
Expand All @@ -347,8 +343,8 @@ fuse:
mountPath: /mnt/alluxio-fuse
resources:
requests:
# cpu: "0.5"
# memory: "1G"
# cpu: "0.5"
# memory: "1G"
limits:
# cpu: "4"
# memory: "4G"
Expand Down
Loading

0 comments on commit 9729a91

Please sign in to comment.