-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
register_kube.go
235 lines (232 loc) · 7.21 KB
/
register_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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package server
import (
"net/http"
"github.com/containers/podman/v5/pkg/api/handlers/libpod"
"github.com/gorilla/mux"
)
func (s *APIServer) registerKubeHandlers(r *mux.Router) error {
// swagger:operation POST /libpod/play/kube libpod PlayKubeLibpod
// ---
// tags:
// - containers
// - pods
// summary: Play a Kubernetes YAML file.
// description: Create and run pods based on a Kubernetes YAML file (pod or service kind).
// parameters:
// - in: query
// name: annotations
// type: string
// description: JSON encoded value of annotations (a map[string]string).
// - in: query
// name: logDriver
// type: string
// description: Logging driver for the containers in the pod.
// - in: query
// name: logOptions
// type: array
// description: logging driver options
// items:
// type: string
// - in: query
// name: network
// type: array
// description: USe the network mode or specify an array of networks.
// items:
// type: string
// - in: query
// name: noHosts
// type: boolean
// default: false
// description: do not setup /etc/hosts file in container
// - in: query
// name: noTrunc
// type: boolean
// default: false
// description: use annotations that are not truncated to the Kubernetes maximum length of 63 characters
// - in: query
// name: publishPorts
// type: array
// description: publish a container's port, or a range of ports, to the host
// items:
// type: string
// - in: query
// name: publishAllPorts
// type: boolean
// description: Whether to publish all ports defined in the K8S YAML file (containerPort, hostPort), if false only hostPort will be published
// - in: query
// name: replace
// type: boolean
// default: false
// description: replace existing pods and containers
// - in: query
// name: serviceContainer
// type: boolean
// default: false
// description: Starts a service container before all pods.
// - in: query
// name: start
// type: boolean
// default: true
// description: Start the pod after creating it.
// - in: query
// name: staticIPs
// type: array
// description: Static IPs used for the pods.
// items:
// type: string
// - in: query
// name: staticMACs
// type: array
// description: Static MACs used for the pods.
// items:
// type: string
// - in: query
// name: tlsVerify
// type: boolean
// default: true
// description: Require HTTPS and verify signatures when contacting registries.
// - in: query
// name: userns
// type: string
// description: Set the user namespace mode for the pods.
// - in: query
// name: wait
// type: boolean
// default: false
// description: Clean up all objects created when a SIGTERM is received or pods exit.
// - in: body
// name: request
// description: Kubernetes YAML file.
// schema:
// type: string
// produces:
// - application/json
// responses:
// 200:
// $ref: "#/responses/playKubeResponseLibpod"
// 500:
// $ref: "#/responses/internalError"
r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKube)).Methods(http.MethodPost)
r.HandleFunc(VersionedPath("/libpod/kube/play"), s.APIHandler(libpod.KubePlay)).Methods(http.MethodPost)
// swagger:operation DELETE /libpod/play/kube libpod PlayKubeDownLibpod
// ---
// tags:
// - containers
// - pods
// summary: Remove resources created from kube play
// description: Tears down pods, secrets, and volumes defined in a YAML file
// parameters:
// - in: query
// name: force
// type: boolean
// default: false
// description: Remove volumes.
// produces:
// - application/json
// responses:
// 200:
// $ref: "#/responses/playKubeResponseLibpod"
// 500:
// $ref: "#/responses/internalError"
r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKubeDown)).Methods(http.MethodDelete)
r.HandleFunc(VersionedPath("/libpod/kube/play"), s.APIHandler(libpod.KubePlayDown)).Methods(http.MethodDelete)
// swagger:operation GET /libpod/generate/kube libpod GenerateKubeLibpod
// ---
// tags:
// - containers
// - pods
// summary: Generate a Kubernetes YAML file.
// description: Generate Kubernetes YAML based on a pod or container.
// parameters:
// - in: query
// name: names
// type: array
// items:
// type: string
// required: true
// description: Name or ID of the container or pod.
// - in: query
// name: service
// type: boolean
// default: false
// description: Generate YAML for a Kubernetes service object.
// - in: query
// name: type
// type: string
// default: pod
// description: Generate YAML for the given Kubernetes kind.
// - in: query
// name: replicas
// type: integer
// format: int32
// default: 0
// description: Set the replica number for Deployment kind.
// - in: query
// name: noTrunc
// type: boolean
// default: false
// description: don't truncate annotations to the Kubernetes maximum length of 63 characters
// - in: query
// name: podmanOnly
// type: boolean
// default: false
// description: add podman-only reserved annotations in generated YAML file (cannot be used by Kubernetes)
// produces:
// - text/vnd.yaml
// - application/json
// responses:
// 200:
// description: Kubernetes YAML file describing pod
// schema:
// type: string
// format: binary
// 500:
// $ref: "#/responses/internalError"
r.HandleFunc(VersionedPath("/libpod/generate/kube"), s.APIHandler(libpod.GenerateKube)).Methods(http.MethodGet)
r.HandleFunc(VersionedPath("/libpod/kube/generate"), s.APIHandler(libpod.KubeGenerate)).Methods(http.MethodGet)
// swagger:operation POST /libpod/kube/apply libpod KubeApplyLibpod
// ---
// tags:
// - containers
// - pods
// summary: Apply a podman workload or Kubernetes YAML file.
// description: Deploy a podman container, pod, volume, or Kubernetes yaml to a Kubernetes cluster.
// parameters:
// - in: query
// name: caCertFile
// type: string
// description: Path to the CA cert file for the Kubernetes cluster.
// - in: query
// name: kubeConfig
// type: string
// description: Path to the kubeconfig file for the Kubernetes cluster.
// - in: query
// name: namespace
// type: string
// description: The namespace to deploy the workload to on the Kubernetes cluster.
// - in: query
// name: service
// type: boolean
// description: Create a service object for the container being deployed.
// - in: query
// name: file
// type: string
// description: Path to the Kubernetes yaml file to deploy.
// - in: body
// name: request
// description: Kubernetes YAML file.
// schema:
// type: string
// produces:
// - application/json
// responses:
// 200:
// description: Kubernetes YAML file successfully deployed to cluster
// schema:
// type: string
// format: binary
// 500:
// $ref: "#/responses/internalError"
r.HandleFunc(VersionedPath("/libpod/kube/apply"), s.APIHandler(libpod.KubeApply)).Methods(http.MethodPost)
return nil
}