-
Notifications
You must be signed in to change notification settings - Fork 10
/
blueprint.yaml
188 lines (162 loc) · 6.8 KB
/
blueprint.yaml
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
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Blueprint for deploying a Kubernetes cluster through Mist.io #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
tosca_definitions_version: cloudify_dsl_1_2
# Imports section. Imports the cloudify-mist-plugin.
imports:
- http://www.getcloudify.org/spec/cloudify/3.3m5/types.yaml
- http://raw.githubusercontent.com/mistio/cloudify-mist-plugin/master/plugin.yaml
# Inputs section.
inputs:
mist_uri:
description: >
The Mist.io URL. Points to the Mist.io service that will handle the
workflows' execution. This input is provided by the application itself,
so no user interaction is necessary. Defaults to the Mist.io SaaS.
type: string
default: 'https://mist.io'
mist_token:
description: >
An API Token generated by Mist.io in order to be used with every request
to authenticate to the Mist.io API. This input is also auto-generated by
Mist.io.
type: string
mist_machine_master:
description: >
The spec of the machine to be used as the kubernetes master node. This
input has to comply with: `cloudify.datatypes.mist.MachineParams`. To
use an existing machine, the `cloud_id` and `machine_id` params should
should only be provided. The `machine_id` key indicates the use of an
existing resource. If the `machine_id` is left blank, then the rest of
the inputs have to be provided according to each cloud provider's spec
and required parameters. Note that `cloud_id` is always required.
mist_machine_worker:
description: >
The spec of the machine to be used as a kubernetes node. The input has
to also comply with `cloudify.datatypes.mist.MachineParams`. The same
rules as in case of `mist_machine_master`, apply here, too.
auth_user:
description: >
The username used for connecting to the kubernetes cluster and accessing
its dashboard. Defaults to 'admin'.
type: string
default: 'admin'
auth_pass:
description: >
The password used for connecting to the kubernetes cluster and accessing
its dashboard. If left blank, it will be auto-generated.
type: string
default: ''
# DSL definitions section.
dsl_definitions:
mist_config: &mist_config
mist_uri: { get_input: mist_uri }
mist_token: { get_input: mist_token }
# Kubernetes node types' section.
node_types:
cloudify.mist.nodes.KubernetesMaster:
derived_from: cloudify.mist.nodes.Server
properties:
master:
description: Indicates the kubernetes master
type: boolean
default: true
configured:
description: Indicates whether kubernetes is already configured
type: boolean
default: false
auth_user:
description: The username used for accessing the kubernetes cluster
type: string
default: 'admin'
auth_pass:
description: The password used for accessing the kubernetes cluster
type: string
default: ''
interfaces:
cloudify.interfaces.lifecycle:
stop: tasks/stop.py
create: tasks/create.py
configure: tasks/configure.py
cloudify.mist.nodes.KubernetesWorker:
derived_from: cloudify.mist.nodes.Server
properties:
master:
type: boolean
default: false
configured:
type: boolean
default: false
interfaces:
cloudify.interfaces.lifecycle:
stop: tasks/stop.py
clone: tasks/clone.py
create: tasks/create.py
configure: tasks/configure.py
# Kubernetes node templates' section.
node_templates:
kube_master:
type: cloudify.mist.nodes.KubernetesMaster
properties:
mist_config: *mist_config
parameters: { get_input: mist_machine_master }
auth_user: { get_input: auth_user }
auth_pass: { get_input: auth_pass }
kube_worker:
type: cloudify.mist.nodes.KubernetesWorker
properties:
mist_config: *mist_config
parameters: { get_input: mist_machine_worker }
relationships:
- target: kube_master
type: cloudify.relationships.connected_to
# Custom workflows sections. Use these to scale the cluster up/down.
workflows:
scale_cluster_up:
mapping: workflows/scale_up.py
parameters:
mist_machine_worker_list:
default: []
description: >
A list of `mist_machine_worker` inputs, as also defined in the
inputs section, used to increase the cluster's size by more than
a single node at once. The size of the list equals the scaling
factor.
scale_cluster_down:
mapping: workflows/scale_down.py
parameters:
delta:
type: integer
default: 0
description: The number of worker nodes to be removed from the cluster
# Outputs section. Run "cfy local outputs" to get useful commands for
# connecting to the cluster and accessing its dashboard.
outputs:
configure_context:
description: Configure kubectl context for cluster
value:
command: { concat: [ 'kubectl config set-cluster ', { get_attribute: [ kube_master, machine_name ] }, '-cluster',
' --insecure-skip-tls-verify=true',
' --server="https://', { get_attribute: [ kube_master, server_ip ] }, '"',
' && kubectl config set-credentials ', { get_attribute: [ kube_master, machine_name ] }, '-admin',
' --username="', { get_attribute: [ kube_master, auth_user ] }, '"',
' --password="', { get_attribute: [ kube_master, auth_pass ] }, '"',
' && kubectl config set-context ', { get_attribute: [ kube_master, machine_name ] }, '-context',
' --cluster=', { get_attribute: [ kube_master, machine_name ] }, '-cluster',
' --user=', { get_attribute: [ kube_master, machine_name ] }, '-admin']}
kubectl_use_context:
description: Switch to the configured context for this cluster
value:
command: { concat: ['kubectl config use-context ', { get_attribute: [ kube_master, machine_name ] }, '-context'] }
kubectl_cluster_info:
description: Kubernetes cluster-info command
value:
command: { concat: [ 'kubectl cluster-info' ] }
start_dashboard_proxy:
description: Kubernetes dashboard URL
value:
command: { concat: [ 'kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml',
' && kubectl proxy' ] }
url: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/