diff --git a/aws-blueprint.yaml b/aws-blueprint.yaml index ba0a81a..6819d24 100644 --- a/aws-blueprint.yaml +++ b/aws-blueprint.yaml @@ -5,12 +5,10 @@ description: > It is based on this documentation: https://kubernetes.io/docs/getting-started-guides/kubeadm/ imports: - - http://www.getcloudify.org/spec/cloudify/4.0.1/types.yaml - - http://getcloudify.org.s3.amazonaws.com/spec/aws-plugin/1.4.9/plugin.yaml - - http://www.getcloudify.org/spec/diamond-plugin/1.3.5/plugin.yaml - - types/scale.yaml - - types/cloud_config/cloud-config.yaml - - types/kubernetes.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/4.1/resources/rest-service/cloudify/types/types.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/1.4.13/plugin.yaml + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-utilities-plugin/1.2.5/plugin.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-diamond-plugin/1.3.5/plugin.yaml - imports/kubernetes.yaml - imports/cloud-config.yaml @@ -168,12 +166,24 @@ node_templates: to_port: 4001 cidr_ip: 0.0.0.0/0 - ip_protocol: tcp + from_port: 4789 + to_port: 4789 + cidr_ip: 0.0.0.0/0 + - ip_protocol: tcp + from_port: 6443 + to_port: 6443 + cidr_ip: 0.0.0.0/0 + - ip_protocol: udp from_port: 6443 to_port: 6443 cidr_ip: 0.0.0.0/0 - ip_protocol: tcp - from_port: 8000 - to_port: 8000 + from_port: 6783 + to_port: 6784 + cidr_ip: 0.0.0.0/0 + - ip_protocol: udp + from_port: 6783 + to_port: 6784 cidr_ip: 0.0.0.0/0 - ip_protocol: tcp from_port: 8080 diff --git a/azure-blueprint.yaml b/azure-blueprint.yaml index a8e56df..14fef37 100644 --- a/azure-blueprint.yaml +++ b/azure-blueprint.yaml @@ -7,14 +7,10 @@ description: > # Several lines are commented. Currently there is not a Centos 7 image that supports Cloud Init. When there is, we will replace the current docker/kubernetes installation method with the commented lines. imports: - - http://www.getcloudify.org/spec/cloudify/4.0.1/types.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/4.1/resources/rest-service/cloudify/types/types.yaml - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-azure-plugin/1.4.3/plugin.yaml - http://www.getcloudify.org/spec/diamond-plugin/1.3.5/plugin.yaml - - types/scale.yaml -# - types/cloud_config/cloud-config.yaml - - types/kubernetes.yaml - imports/kubernetes.yaml -# - imports/cloud-config.yaml inputs: @@ -334,6 +330,17 @@ node_templates: priority: 108 access: Allow direction: Inbound + - name: {concat:[{get_input: resource_prefix},nsg,{get_input: resource_suffix},4789tcp]} + properties: + description: 4789 TCP access + protocol: Tcp + sourcePortRange: '*' + destinationPortRange: 4789 + sourceAddressPrefix: '*' + destinationAddressPrefix: '*' + priority: 1080 + access: Allow + direction: Inbound - name: {concat:[{get_input: resource_prefix},nsg,{get_input: resource_suffix},6443tcp]} properties: description: 6443 TCP access @@ -345,6 +352,50 @@ node_templates: priority: 109 access: Allow direction: Inbound + - name: {concat:[{get_input: resource_prefix},nsg,{get_input: resource_suffix},6783tcp]} + properties: + description: 6783 TCP access + protocol: Tcp + sourcePortRange: '*' + destinationPortRange: 6783 + sourceAddressPrefix: '*' + destinationAddressPrefix: '*' + priority: 1090 + access: Allow + direction: Inbound + - name: {concat:[{get_input: resource_prefix},nsg,{get_input: resource_suffix},6784tcp]} + properties: + description: 6784 TCP access + protocol: Tcp + sourcePortRange: '*' + destinationPortRange: 6784 + sourceAddressPrefix: '*' + destinationAddressPrefix: '*' + priority: 1091 + access: Allow + direction: Inbound + - name: {concat:[{get_input: resource_prefix},nsg,{get_input: resource_suffix},6783udp]} + properties: + description: 6783 UDP access + protocol: Udp + sourcePortRange: '*' + destinationPortRange: 6783 + sourceAddressPrefix: '*' + destinationAddressPrefix: '*' + priority: 1092 + access: Allow + direction: Inbound + - name: {concat:[{get_input: resource_prefix},nsg,{get_input: resource_suffix},6784udp]} + properties: + description: 6784 UDP access + protocol: Udp + sourcePortRange: '*' + destinationPortRange: 6784 + sourceAddressPrefix: '*' + destinationAddressPrefix: '*' + priority: 1093 + access: Allow + direction: Inbound - name: {concat:[{get_input: resource_prefix},nsg,{get_input: resource_suffix},8000tcp]} properties: description: 8000 TCP access diff --git a/imports/cloud-config.yaml b/imports/cloud-config.yaml index cd2723a..0dfb954 100644 --- a/imports/cloud-config.yaml +++ b/imports/cloud-config.yaml @@ -1,47 +1,41 @@ node_templates: cloudify_host_cloud_config: - type: cloudify.nodes.CloudConfig + type: cloudify.nodes.CloudInit.CloudConfig properties: resource_config: - encode_base64: { get_input: encode_cloud_config } - interfaces: - cloudify.interfaces.lifecycle: - create: - inputs: - cloud_config: - groups: - - docker - users: - - name: { get_input: agent_user } - primary-group: wheel - groups: docker - shell: /bin/bash - sudo: ['ALL=(ALL) NOPASSWD:ALL'] - ssh-authorized-keys: - - { get_secret: agent_key_public } - write_files: - - path: /etc/yum.repos.d/kubernetes.repo - owner: root:root - permissions: '0444' - content: | - # installed by cloud-init - [kubernetes] - name=Kubernetes - baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 - enabled=1 - gpgcheck=1 - repo_gpgcheck=1 - gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg - packages: - - [docker, 1.12.6-28.git1398f24.el7.centos] - - [kubelet, 1.6.4-0] - - [kubeadm, 1.6.4-0] - - [kubectl, 1.6.4-0] - - [kubernetes-cni, 0.5.1-0] - runcmd: - - [ systemctl, enable, docker ] - - [ systemctl, start, docker ] - - [ systemctl, enable, kubelet ] - - [ systemctl, start, kubelet ] + groups: + - docker + users: + - name: { get_input: agent_user } + primary-group: wheel + groups: docker + shell: /bin/bash + sudo: ['ALL=(ALL) NOPASSWD:ALL'] + ssh-authorized-keys: + - { get_secret: agent_key_public } + write_files: + - path: /etc/yum.repos.d/kubernetes.repo + owner: root:root + permissions: '0444' + content: | + # installed by cloud-init + [kubernetes] + name=Kubernetes + baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 + enabled=1 + gpgcheck=1 + repo_gpgcheck=1 + gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg + https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg + packages: + - [docker, 1.12.6-28.git1398f24.el7.centos] + - [kubelet, 1.6.4-0] + - [kubeadm, 1.6.4-0] + - [kubectl, 1.6.4-0] + - [kubernetes-cni, 0.5.1-0] + runcmd: + - [ systemctl, enable, docker ] + - [ systemctl, start, docker ] + - [ systemctl, enable, kubelet ] + - [ systemctl, start, kubelet ] diff --git a/imports/kubernetes.yaml b/imports/kubernetes.yaml index aac8791..abbf4ef 100644 --- a/imports/kubernetes.yaml +++ b/imports/kubernetes.yaml @@ -1,3 +1,32 @@ +node_types: + + cloudify.nodes.Kubernetes: + derived_from: cloudify.nodes.Root + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: scripts/create.py + + cloudify.nodes.Kubernetes.Master: + derived_from: cloudify.nodes.Root + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: scripts/create.py + configure: + implementation: scripts/configure_master.py + start: + implementation: scripts/start_master.py + + cloudify.nodes.Kubernetes.Node: + derived_from: cloudify.nodes.Root + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: scripts/create.py + configure: + implementation: scripts/configure_node.py + node_templates: kubernetes_master: @@ -14,6 +43,36 @@ node_templates: - type: cloudify.relationships.depends_on target: kubernetes_master +outputs: + + kubernetes_master_configuration: + value: { get_attribute: [ kubernetes_master, configuration_file_content ] } + + +policy_types: + scale_policy_type: + source: policies/scale.clj + properties: + policy_operates_on_group: + default: true + service_selector: + description: regular expression that selects the metric to be measured + default: ".*" + moving_window_size: + description: the moving window for individual sources in secs + default: 10 + scale_threshold: + description: the value to trigger scaling over aggregrated moving values + scale_limit: + description: scaling limit + default: 10 + scale_direction: + description: scale up ('<') or scale down ('>') + default: '<' + cooldown_time: + description: the time to wait before evaluating again after a scale + default: 60 + groups: scale_up_group: diff --git a/openstack-blueprint.yaml b/openstack-blueprint.yaml index 1b3a538..01142b0 100644 --- a/openstack-blueprint.yaml +++ b/openstack-blueprint.yaml @@ -5,32 +5,29 @@ description: > It is based on this documentation: https://kubernetes.io/docs/getting-started-guides/kubeadm/ imports: - - http://www.getcloudify.org/spec/cloudify/4.0.1/types.yaml - - http://www.getcloudify.org/spec/openstack-plugin/2.0.1/plugin.yaml - - http://www.getcloudify.org/spec/fabric-plugin/1.3.1/plugin.yaml - - http://www.getcloudify.org/spec/diamond-plugin/1.3.5/plugin.yaml - - types/scale.yaml - - types/cloud_config/cloud-config.yaml - - types/kubernetes.yaml - - imports/kubernetes.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/4.1/resources/rest-service/cloudify/types/types.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-openstack-plugin/2.2.0/plugin.yaml + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-utilities-plugin/1.2.5/plugin.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-fabric-plugin/1.5/plugin.yaml + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-diamond-plugin/1.3.5/plugin.yaml - imports/cloud-config.yaml + - imports/kubernetes.yaml inputs: image: description: Image to be used when launching agent VMs + default: { get_secret: centos_core_image } flavor: description: Flavor of the agent VMs + default: { get_secret: large_image_flavor } agent_user: description: > User for connecting to agent VMs default: centos - encode_cloud_config: - default: false - dsl_definitions: openstack_config: &openstack_config diff --git a/scripts/cloud_config/create.py b/scripts/cloud_config/create.py deleted file mode 100644 index c9051f7..0000000 --- a/scripts/cloud_config/create.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -try: - import yaml -except ImportError: - import pip - pip.main(['install', 'pyyaml']) - import yaml - -import base64 -from cloudify import ctx -from cloudify.state import ctx_parameters as inputs - - -if __name__ == '__main__': - - cloud_config = inputs['cloud_config'] - ctx.logger.debug('cloud_config: {0}'.format(cloud_config)) - cloud_config_yaml = yaml.dump(cloud_config) - cloud_config_string = str(cloud_config_yaml).replace('!!python/unicode ', '') - cloud_config_string = '#cloud-config\n' + cloud_config_string - ctx.logger.debug('cloud_config_string: {0}'.format(cloud_config_string)) - - if ctx.node.properties['resource_config'].get('encode_base64'): - cloud_config_string = base64.encodestring(cloud_config_string) - ctx.logger.debug('cloud_config_string: {0}'.format(cloud_config_string)) - - ctx.instance.runtime_properties['cloud_config'] = cloud_config_string diff --git a/scripts/configure_master.py b/scripts/configure_master.py index 5c67005..a691fa3 100644 --- a/scripts/configure_master.py +++ b/scripts/configure_master.py @@ -6,6 +6,7 @@ import getpass import subprocess from cloudify import ctx +from cloudify.exceptions import OperationRetry def execute_command(_command): @@ -39,6 +40,9 @@ def execute_command(_command): # Start the Kube Master start_output = execute_command('sudo kubeadm init --skip-preflight-checks') + if isinstance(start_output, bool): + execute_command('sudo kubeadm reset') + raise OperationRetry('Restarting kubernetes because of a problem.') for line in start_output.split('\n'): if 'kubeadm join' in line: ctx.instance.runtime_properties['join_command'] = line.lstrip() @@ -62,4 +66,4 @@ def execute_command(_command): execute_command('sudo chmod a+x /usr/local/bin/weave') execute_command('sudo curl -L git.io/scope -o /usr/local/bin/scope') execute_command('sudo chmod a+x /usr/local/bin/scope') - execute_command('scope launch') + execute_command('/usr/local/bin/scope launch') diff --git a/scripts/configure_node.py b/scripts/configure_node.py index 9d22dae..8629069 100644 --- a/scripts/configure_node.py +++ b/scripts/configure_node.py @@ -47,4 +47,4 @@ def execute_command(_command): execute_command('sudo chmod a+x /usr/local/bin/weave') execute_command('sudo curl -L git.io/scope -o /usr/local/bin/scope') execute_command('sudo chmod a+x /usr/local/bin/scope') - execute_command('scope launch') + execute_command('/usr/local/bin/scope launch') diff --git a/types/cloud_config/cloud-config.yaml b/types/cloud_config/cloud-config.yaml deleted file mode 100644 index 2fe4b20..0000000 --- a/types/cloud_config/cloud-config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -node_types: - - cloudify.nodes.CloudConfig: - derived_from: cloudify.nodes.Root - properties: - resource_config: - default: - encode_base64: false - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: scripts/cloud_config/create.py - executor: central_deployment_agent diff --git a/types/docker.yaml b/types/docker.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/types/kubernetes.yaml b/types/kubernetes.yaml deleted file mode 100644 index 7a0054f..0000000 --- a/types/kubernetes.yaml +++ /dev/null @@ -1,28 +0,0 @@ -node_types: - - cloudify.nodes.Kubernetes: - derived_from: cloudify.nodes.Root - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: scripts/create.py - - cloudify.nodes.Kubernetes.Master: - derived_from: cloudify.nodes.Root - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: scripts/create.py - configure: - implementation: scripts/configure_master.py - start: - implementation: scripts/start_master.py - - cloudify.nodes.Kubernetes.Node: - derived_from: cloudify.nodes.Root - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: scripts/create.py - configure: - implementation: scripts/configure_node.py diff --git a/types/scale.yaml b/types/scale.yaml deleted file mode 100644 index 326ba94..0000000 --- a/types/scale.yaml +++ /dev/null @@ -1,24 +0,0 @@ - -policy_types: - scale_policy_type: - source: policies/scale.clj - properties: - policy_operates_on_group: - default: true - service_selector: - description: regular expression that selects the metric to be measured - default: ".*" - moving_window_size: - description: the moving window for individual sources in secs - default: 10 - scale_threshold: - description: the value to trigger scaling over aggregrated moving values - scale_limit: - description: scaling limit - default: 10 - scale_direction: - description: scale up ('<') or scale down ('>') - default: '<' - cooldown_time: - description: the time to wait before evaluating again after a scale - default: 60