forked from ceph/cn
/
kube.go
164 lines (156 loc) · 3.9 KB
/
kube.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* Ceph Nano (C) 2017 Red Hat, Inc.
*
* 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.
*/
/*
* Below main package has canonical imports for 'go get' and 'go build'
* to work with all other clones of github.com/ceph/cn repository. For
* more information refer https://golang.org/doc/go1.4#canonicalimports
*/
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func cliKubeNano() *cobra.Command {
cmd := &cobra.Command{
Use: "kube",
Short: "Outputs cn kubernetes template (cn kube > kube-cn.yml)",
Args: cobra.NoArgs,
Run: kubeTemplate,
}
return cmd
}
func kubeTemplate(cmd *cobra.Command, args []string) {
kubeTmp := `
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cn-pv-claim-var
labels:
app: ceph
daemon: nano
spec:
# Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
# Uncomment and add storageClass specific to your requirements below. Read more https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
#storageClassName:
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cn-pv-claim-etc
labels:
app: ceph
daemon: nano
spec:
# Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
# Uncomment and add storageClass specific to your requirements below. Read more https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
#storageClassName:
---
apiVersion: v1
kind: Service
metadata:
name: ceph-nano-s3
labels:
app: ceph
daemon: nano
spec:
ports:
- name: cn-s3
port: 80
protocol: TCP
targetPort: 8000
type: LoadBalancer
selector:
app: ceph
daemon: nano
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ceph-nano
labels:
app: ceph
daemon: nano
name: ceph-nano
spec:
replicas: 1
serviceName: ceph-nano
selector:
matchLabels:
app: ceph
template:
metadata:
name: ceph-nano
labels:
app: ceph
daemon: nano
spec:
containers:
- image: ceph/daemon
imagePullPolicy: Always
name: ceph-nano
ports:
- containerPort: 8000
name: cn-s3
protocol: TCP
resources:
limits:
cpu: "1"
memory: 512M
requests:
cpu: "1"
memory: 512M
env:
- name: NETWORK_AUTO_DETECT
value: "4"
- name: RGW_FRONTEND_PORT
value: "8000"
# Keep this for backward compatiblity, the option is gone since https://github.com/ceph/ceph-container/pull/1356
- name: RGW_CIVETWEB_PORT
value: "8000"
- name: SREE_PORT
value: "5001"
- name: CEPH_DEMO_UID
value: "nano"
- name: CEPH_DAEMON
value: "demo"
- name: DEBUG
value: "verbose"
volumeMounts:
- name: cn-varlibceph
mountPath: /var/lib/ceph
- name: cn-etcceph
mountPath: /etc/ceph
volumes:
- name: cn-varlibceph
persistentVolumeClaim:
claimName: cn-pv-claim-var
- name: cn-etcceph
persistentVolumeClaim:
claimName: cn-pv-claim-etc
`
fmt.Print(kubeTmp)
}