Files
my-rook-config/tests/framework/installer/install_data.go
T

253 lines
5.3 KiB
Go
Raw Normal View History

2017-07-21 12:07:15 -07:00
/*
Copyright 2016 The Rook Authors. All rights reserved.
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 installer
import (
"strconv"
)
2017-07-21 12:07:15 -07:00
//InstallData wraps rook yaml definitions
type InstallData struct {
}
//NewK8sInstallData creates new instance of InstallData struct
func NewK8sInstallData() *InstallData {
return &InstallData{}
}
//GetRookOperator returns rook Operator manifest
2017-10-12 16:03:08 -07:00
func (i *InstallData) GetRookOperator(namespace string) string {
2017-07-21 12:07:15 -07:00
return `kind: Namespace
apiVersion: v1
metadata:
2017-10-17 23:08:07 -07:00
name: ` + namespace + `
---
kind: ClusterRole
2017-07-21 12:07:15 -07:00
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: rook-operator
rules:
- apiGroups:
- ""
resources:
- namespaces
- serviceaccounts
- secrets
- pods
- services
- nodes
- nodes/proxy
2017-07-21 12:07:15 -07:00
- configmaps
- events
- persistentvolumes
- persistentvolumeclaims
verbs:
- get
- list
- watch
- patch
- create
- update
- delete
- apiGroups:
- extensions
resources:
- thirdpartyresources
- deployments
- daemonsets
- replicasets
verbs:
- get
- list
- watch
- create
- delete
2017-07-24 07:43:11 -07:00
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
- list
- watch
- create
- delete
2017-07-21 12:07:15 -07:00
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- clusterrolebindings
- roles
- rolebindings
2017-07-21 12:07:15 -07:00
verbs:
- get
- list
- watch
- create
- update
- delete
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- delete
- apiGroups:
- rook.io
resources:
- "*"
verbs:
- "*"
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: rook-operator
2017-10-17 23:08:07 -07:00
namespace: ` + namespace + `
2017-07-21 12:07:15 -07:00
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: rook-operator
2017-10-17 23:08:07 -07:00
namespace: ` + namespace + `
2017-07-21 12:07:15 -07:00
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: rook-operator
subjects:
- kind: ServiceAccount
name: rook-operator
2017-10-17 23:08:07 -07:00
namespace: ` + namespace + `
2017-07-21 12:07:15 -07:00
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: rook-operator
2017-10-17 23:08:07 -07:00
namespace: ` + namespace + `
2017-07-21 12:07:15 -07:00
spec:
replicas: 1
template:
metadata:
labels:
app: rook-operator
spec:
serviceAccountName: rook-operator
containers:
- name: rook-operator
image: rook/rook:master
args: ["operator", "--mon-healthcheck-interval=5s", "--mon-out-timeout=1s"]
2017-07-21 12:07:15 -07:00
env:
2017-09-09 17:33:28 +02:00
- name: ROOK_LOG_LEVEL
value: INFO
# The interval to check if every mon is in the quorum.
- name: ROOK_MON_HEALTHCHECK_INTERVAL
value: "20s"
# The duration to wait before trying to failover or remove/replace the
# current mon with a new mon (useful for compensating flapping network).
- name: ROOK_MON_OUT_TIMEOUT
value: "300s"
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace`
2017-07-21 12:07:15 -07:00
}
//GetRookCluster returns rook-cluster manifest
func (i *InstallData) GetRookCluster(namespace, storeType, dataDirHostPath string, useAllDevices bool, mons int) string {
return `apiVersion: rook.io/v1alpha1
2017-07-21 12:07:15 -07:00
kind: Cluster
metadata:
name: ` + namespace + `
namespace: ` + namespace + `
2017-07-21 12:07:15 -07:00
spec:
dataDirHostPath: ` + dataDirHostPath + `
2017-09-09 17:33:28 +02:00
hostNetwork: false
monCount: ` + strconv.Itoa(mons) + `
2017-10-06 17:26:39 -07:00
storage:
2017-07-21 12:07:15 -07:00
useAllNodes: true
useAllDevices: ` + strconv.FormatBool(useAllDevices) + `
2017-07-21 12:07:15 -07:00
deviceFilter:
metadataDevice:
location:
storeConfig:
2017-10-06 17:26:39 -07:00
storeType: ` + storeType + `
databaseSizeMB: 1024
journalSizeMB: 1024
`
2017-07-21 12:07:15 -07:00
}
//GetRookToolBox returns rook-toolbox manifest
func (i *InstallData) GetRookToolBox(namespace string) string {
2017-07-21 12:07:15 -07:00
return `apiVersion: v1
kind: Pod
metadata:
name: rook-tools
namespace: ` + namespace + `
2017-07-21 12:07:15 -07:00
spec:
dnsPolicy: ClusterFirstWithHostNet
2017-07-21 12:07:15 -07:00
containers:
- name: rook-tools
image: rook/toolbox:master
imagePullPolicy: IfNotPresent
env:
2017-08-04 09:51:23 -07:00
- name: ROOK_ADMIN_SECRET
2017-07-21 12:07:15 -07:00
valueFrom:
secretKeyRef:
name: rook-ceph-mon
key: admin-secret
securityContext:
privileged: true
volumeMounts:
- mountPath: /dev
name: dev
- mountPath: /sys/bus
name: sysbus
- mountPath: /lib/modules
name: libmodules
- name: mon-endpoint-volume
mountPath: /etc/rook
hostNetwork: false
2017-07-21 12:07:15 -07:00
volumes:
- name: dev
hostPath:
path: /dev
- name: sysbus
hostPath:
path: /sys/bus
- name: libmodules
hostPath:
path: /lib/modules
- name: mon-endpoint-volume
configMap:
name: rook-ceph-mon-endpoints
items:
- key: data
path: mon-endpoints`
2017-07-21 12:07:15 -07:00
}