Skip to content

Commit 8a74b79

Browse files
authored
Add kubernetes kustomize yaml files (#188)
1 parent b7614b6 commit 8a74b79

13 files changed

+590
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
PWD := $(shell pwd)
22
GOPATH := $(shell go env GOPATH)
3+
# Sets the build version based on the output of the following command, if we are building for a tag, that's the build else it uses the current git branch as the build
4+
BUILD_VERSION:=$(shell git describe --exact-match --tags $(git log -n1 --pretty='%h') 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null)
5+
BUILD_TIME:=$(shell date 2>/dev/null)
6+
TAG ?= "minio/m3:$(VERSION)-dev"
37

48
default: mcs
59

@@ -8,6 +12,11 @@ mcs:
812
@echo "Building mcs binary to './mcs'"
913
@(GO111MODULE=on CGO_ENABLED=0 go build -trimpath --tags=kqueue --ldflags "-s -w" -o mcs ./cmd/mcs)
1014

15+
k8sdev:
16+
@docker build -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' .
17+
@kind load docker-image $(TAG)
18+
@echo "Done, now restart your mcs deployment"
19+
1120
getdeps:
1221
@mkdir -p ${GOPATH}/bin
1322
@which golangci-lint 1>/dev/null || (echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.27.0)

k8s/base/kustomization.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
# beginning of customizations
4+
resources:
5+
- mcs-service-account.yaml
6+
- mcs-cluster-role.yaml
7+
- mcs-cluster-role-binding.yaml
8+
- mcs-configmap.yaml
9+
- mcs-service.yaml
10+
- mcs-deployment.yaml
11+
- minio-operator.yaml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kind: ClusterRoleBinding
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: mcs-sa-binding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: mcs-sa-role
9+
subjects:
10+
- kind: ServiceAccount
11+
name: mcs-sa
12+
namespace: default

k8s/base/mcs-cluster-role.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: mcs-sa-role
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- namespaces
10+
- secrets
11+
- pods
12+
- services
13+
- events
14+
- resourcequotas
15+
verbs:
16+
- get
17+
- watch
18+
- create
19+
- list
20+
- patch
21+
- apiGroups:
22+
- "storage.k8s.io"
23+
resources:
24+
- storageclasses
25+
verbs:
26+
- get
27+
- watch
28+
- create
29+
- list
30+
- patch
31+
- apiGroups:
32+
- apps
33+
resources:
34+
- statefulsets
35+
- deployments
36+
verbs:
37+
- get
38+
- create
39+
- list
40+
- patch
41+
- watch
42+
- update
43+
- delete
44+
- apiGroups:
45+
- batch
46+
resources:
47+
- jobs
48+
verbs:
49+
- get
50+
- create
51+
- list
52+
- patch
53+
- watch
54+
- update
55+
- delete
56+
- apiGroups:
57+
- "certificates.k8s.io"
58+
resources:
59+
- "certificatesigningrequests"
60+
- "certificatesigningrequests/approval"
61+
- "certificatesigningrequests/status"
62+
verbs:
63+
- update
64+
- create
65+
- get
66+
- apiGroups:
67+
- operator.min.io
68+
resources:
69+
- "*"
70+
verbs:
71+
- "*"
72+
- apiGroups:
73+
- min.io
74+
resources:
75+
- "*"
76+
verbs:
77+
- "*"

k8s/base/mcs-configmap.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: mcs-env
5+
data:
6+
MCS_PORT: "9090"
7+
MCS_TLS_PORT: "9443"

k8s/base/mcs-deployment.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: mcs
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: mcs
10+
template:
11+
metadata:
12+
labels:
13+
app: mcs
14+
spec:
15+
serviceAccountName: m3-sa
16+
containers:
17+
- name: mcs
18+
image: minio/mcs:latest
19+
imagePullPolicy: "IfNotPresent"
20+
env:
21+
- name: MCS_MKUBE_ADMIN_ONLY
22+
value: "on"
23+
args:
24+
- /mcs
25+
- server
26+
ports:
27+
- containerPort: 9090
28+
name: http
29+
- containerPort: 9433
30+
name: https

k8s/base/mcs-service-account.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: mcs-sa
5+
namespace: default

k8s/base/mcs-service.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mcs
5+
labels:
6+
name: mcs
7+
spec:
8+
ports:
9+
- port: 9090
10+
name: http
11+
- port: 9443
12+
name: https
13+
selector:
14+
app: mcs

k8s/base/minio-operator.yaml

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: minioinstances.operator.min.io
5+
spec:
6+
group: operator.min.io
7+
scope: Namespaced
8+
names:
9+
kind: MinIOInstance
10+
singular: minioinstance
11+
plural: minioinstances
12+
versions:
13+
- name: v1
14+
served: true
15+
storage: true
16+
schema:
17+
# openAPIV3Schema is the schema for validating custom objects.
18+
# Refer https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#specifying-a-structural-schema
19+
# for more details
20+
openAPIV3Schema:
21+
type: object
22+
properties:
23+
spec:
24+
type: object
25+
x-kubernetes-preserve-unknown-fields: true
26+
properties:
27+
replicas:
28+
type: integer
29+
minimum: 1
30+
maximum: 32
31+
image:
32+
type: string
33+
serviceName:
34+
type: string
35+
volumesPerServer:
36+
type: integer
37+
mountPath:
38+
type: string
39+
podManagementPolicy:
40+
type: string
41+
enum: [Parallel, OrderedReady]
42+
default: Parallel
43+
requestAutoCert:
44+
type: boolean
45+
default: false
46+
version:
47+
type: string
48+
mountpath:
49+
type: string
50+
subpath:
51+
type: string
52+
mcs:
53+
type: object
54+
x-kubernetes-preserve-unknown-fields: true
55+
properties:
56+
image:
57+
type: string
58+
replicas:
59+
type: integer
60+
default: 2
61+
mcsSecret:
62+
type: object
63+
properties:
64+
name:
65+
type: string
66+
kes:
67+
type: object
68+
x-kubernetes-preserve-unknown-fields: true
69+
properties:
70+
image:
71+
type: string
72+
replicas:
73+
type: integer
74+
default: 2
75+
kesSecret:
76+
type: object
77+
properties:
78+
name:
79+
type: string
80+
status:
81+
type: object
82+
properties:
83+
currentState:
84+
type: string
85+
subresources:
86+
# status enables the status subresource.
87+
status: {}
88+
additionalPrinterColumns:
89+
- name: Current State
90+
type: string
91+
jsonPath: ".status.currentState"
92+
---
93+
apiVersion: rbac.authorization.k8s.io/v1beta1
94+
kind: ClusterRole
95+
metadata:
96+
name: minio-operator-role
97+
rules:
98+
- apiGroups:
99+
- ""
100+
resources:
101+
- namespaces
102+
- secrets
103+
- pods
104+
- services
105+
- events
106+
verbs:
107+
- get
108+
- watch
109+
- create
110+
- list
111+
- delete
112+
- apiGroups:
113+
- apps
114+
resources:
115+
- statefulsets
116+
- deployments
117+
verbs:
118+
- get
119+
- create
120+
- list
121+
- patch
122+
- watch
123+
- update
124+
- delete
125+
- apiGroups:
126+
- batch
127+
resources:
128+
- jobs
129+
verbs:
130+
- get
131+
- create
132+
- list
133+
- patch
134+
- watch
135+
- update
136+
- delete
137+
- apiGroups:
138+
- "certificates.k8s.io"
139+
resources:
140+
- "certificatesigningrequests"
141+
- "certificatesigningrequests/approval"
142+
- "certificatesigningrequests/status"
143+
verbs:
144+
- update
145+
- create
146+
- get
147+
- delete
148+
- apiGroups:
149+
- operator.min.io
150+
resources:
151+
- "*"
152+
verbs:
153+
- "*"
154+
- apiGroups:
155+
- min.io
156+
resources:
157+
- "*"
158+
verbs:
159+
- "*"
160+
---
161+
apiVersion: v1
162+
kind: ServiceAccount
163+
metadata:
164+
name: minio-operator
165+
namespace: default
166+
---
167+
kind: ClusterRoleBinding
168+
apiVersion: rbac.authorization.k8s.io/v1beta1
169+
metadata:
170+
name: minio-operator-binding
171+
roleRef:
172+
apiGroup: rbac.authorization.k8s.io
173+
kind: ClusterRole
174+
name: minio-operator-role
175+
subjects:
176+
- kind: ServiceAccount
177+
name: minio-operator
178+
namespace: default
179+
---
180+
apiVersion: apps/v1
181+
kind: Deployment
182+
metadata:
183+
name: minio-operator
184+
namespace: default
185+
spec:
186+
replicas: 1
187+
selector:
188+
matchLabels:
189+
name: minio-operator
190+
template:
191+
metadata:
192+
labels:
193+
name: minio-operator
194+
spec:
195+
serviceAccountName: minio-operator
196+
containers:
197+
- name: minio-operator
198+
image: minio/k8s-operator:2.0.8
199+
imagePullPolicy: IfNotPresent
200+
# To specify cluster domain, un comment the following:
201+
# env:
202+
# - name: CLUSTER_DOMAIN
203+
# value: mycluster.mydomain

0 commit comments

Comments
 (0)