-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.jinja
70 lines (66 loc) · 2.79 KB
/
cluster.jinja
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
{#
Copyright 2016 Google Inc. 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.
{% set NAME_PREFIX = env['deployment'] + '-' + env['name']/ %}
#}
{% set NAME_PREFIX = env['deployment'] %}
{% set CLUSTER_NAME = NAME_PREFIX %}
{% set TYPE_NAME = NAME_PREFIX + '-type' %}
{% set K8S_ENDPOINTS = {'': 'api/v1', '-apps': 'apis/apps/v1beta1', '-v1beta1-extensions': 'apis/extensions/v1beta1'} %}
resources:
- name: {{ CLUSTER_NAME }}
type: container.v1.cluster
properties:
zone: {{ properties['zone'] }}
cluster:
name: {{ CLUSTER_NAME }}
initialNodeCount: {{ properties['initialNodeCount'] }}
nodeConfig:
oauthScopes:
- https://www.googleapis.com/auth/compute
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring
{% for typeSuffix, endpoint in K8S_ENDPOINTS.iteritems() %}
- name: {{ TYPE_NAME }}{{ typeSuffix }}
type: deploymentmanager.v2beta.typeProvider
properties:
options:
validationOptions:
# Kubernetes API accepts ints, in fields they annotate with string.
# This validation will show as warning rather than failure for
# Deployment Manager.
# https://github.com/kubernetes/kubernetes/issues/2971
schemaValidation: IGNORE_WITH_WARNINGS
# According to kubernetes spec, the path parameter 'name'
# should be the value inside the metadata field
# https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md
# This mapping specifies that
inputMappings:
- fieldName: name
location: PATH
methodMatch: ^(GET|DELETE|PUT)$
value: $.ifNull($.resource.properties.metadata.name, $.resource.name)
- fieldName: metadata.name
location: BODY
methodMatch: ^(PUT|POST)$
value: $.ifNull($.resource.properties.metadata.name, $.resource.name)
- fieldName: Authorization
location: HEADER
value: >
$.concat("Bearer ", $.googleOauth2AccessToken())
descriptorUrl: https://$(ref.{{ CLUSTER_NAME }}.endpoint)/swaggerapi/{{ endpoint }}
{% endfor %}
outputs:
{% for typeSuffix, endpoint in K8S_ENDPOINTS.iteritems() %}
- name: clusterType{{ typeSuffix }}
value: {{ TYPE_NAME }}{{ typeSuffix }}
{% endfor %}