Merge "Update for changes in k8s 0.15"
This commit is contained in:
commit
e4645044e1
@ -91,6 +91,11 @@ Methods:
|
|||||||
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||||
- $.setAttr(deployed, true)
|
- $.setAttr(deployed, true)
|
||||||
|
|
||||||
|
- $prevNodeCount: $.getAttr(lastNodeCount, 0)
|
||||||
|
- $prevGatewayCount: $.getAttr(lastGatewayCount, 0)
|
||||||
|
|
||||||
|
- If: $prevNodeCount != $.nodeCount or $prevGatewayCount != $.gatewayCount
|
||||||
|
Then:
|
||||||
- $._environment.reporter.report($this, 'Setting up Kubernetes cluster')
|
- $._environment.reporter.report($this, 'Setting up Kubernetes cluster')
|
||||||
- Parallel:
|
- Parallel:
|
||||||
- Do: $.masterNode.deployInstance()
|
- Do: $.masterNode.deployInstance()
|
||||||
@ -106,7 +111,9 @@ Methods:
|
|||||||
- Do: $.minionNodes.take($.nodeCount).pselect($.setupNode())
|
- Do: $.minionNodes.take($.nodeCount).pselect($.setupNode())
|
||||||
- Do: $.minionNodes.skip($.nodeCount).pselect($.removeFromCluster())
|
- Do: $.minionNodes.skip($.nodeCount).pselect($.removeFromCluster())
|
||||||
- Do: $.gatewayNodes.take($.gatewayCount).pselect($.setupNode())
|
- Do: $.gatewayNodes.take($.gatewayCount).pselect($.setupNode())
|
||||||
- $._updateEndpoints()
|
- $._updateServicePublicIps()
|
||||||
|
- $.setAttr(lastNodeCount, $.nodeCount)
|
||||||
|
- $.setAttr(lastGatewayCount, $.gatewayCount)
|
||||||
- $._environment.reporter.report($this, 'Kubernetes cluster is up and running')
|
- $._environment.reporter.report($this, 'Kubernetes cluster is up and running')
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +179,7 @@ Methods:
|
|||||||
- $.masterNode.instance.agent.call($template, $resources)
|
- $.masterNode.instance.agent.call($template, $resources)
|
||||||
|
|
||||||
|
|
||||||
createServices:
|
createService:
|
||||||
Arguments:
|
Arguments:
|
||||||
- applicationName:
|
- applicationName:
|
||||||
Contract: $.string().notNull()
|
Contract: $.string().notNull()
|
||||||
@ -182,58 +189,138 @@ Methods:
|
|||||||
- podId:
|
- podId:
|
||||||
Contract: $.string().notNull()
|
Contract: $.string().notNull()
|
||||||
Body:
|
Body:
|
||||||
- $resources: new(sys:Resources)
|
- $currentEndpoints: $.serviceEndpoints.where($.applicationName = $applicationName and $.podId = $podId and $.scope = internal)
|
||||||
|
- $serviceName: format('svc-{0}', randomName())
|
||||||
- $applicationServices: {}
|
- $endpointMap: {}
|
||||||
- For: endpoint
|
- For: endpoint
|
||||||
In: $.serviceEndpoints.where($.applicationName = $applicationName).where($.serviceName != null)
|
In: $currentEndpoints
|
||||||
Do:
|
Do:
|
||||||
- $serviceName: $endpoint.serviceName
|
- $serviceName: $endpoint.serviceName
|
||||||
- $applicationServices[$serviceName]: $endpoint
|
- $key: format('{0}-{1}', $endpoint.containerPort, $endpoint.protocol)
|
||||||
|
- $endpointMap[$key]: $endpoint
|
||||||
|
|
||||||
- $.serviceEndpoints: $.serviceEndpoints.where($.applicationName != $applicationName)
|
- $serviceChanged: len(list($applicationPorts.where($.scope != host))) != len($currentEndpoints)
|
||||||
|
|
||||||
- $servicesUsed: []
|
- $servicePorts: []
|
||||||
- For: applicationPort
|
- For: applicationPort
|
||||||
In: $applicationPorts
|
In: $applicationPorts.where($.scope != host)
|
||||||
Do:
|
Do:
|
||||||
- If: $applicationPort.scope != host
|
- $key: format('{0}-{1}', $applicationPort.port, $applicationPort.protocol)
|
||||||
|
- $endpoint: $endpointMap.get($key)
|
||||||
|
- If: $endpoint != null
|
||||||
Then:
|
Then:
|
||||||
- $serviceName: null
|
- $record:
|
||||||
- $reuseEndpoint: null
|
- assignedPort: $endpoint.port
|
||||||
- For: service
|
applicationPort: $applicationPort
|
||||||
In: $applicationServices.keys()
|
|
||||||
Do:
|
|
||||||
- $endpoint: $applicationServices.get($service)
|
|
||||||
- If: $endpoint.containerPort = $applicationPort.port and $endpoint.protocol = $applicationPort.protocol
|
|
||||||
Then:
|
|
||||||
- $serviceName: $service
|
|
||||||
- $reuseEndpoint: $endpoint
|
|
||||||
- Break:
|
|
||||||
|
|
||||||
- If: $serviceName = null
|
|
||||||
Then:
|
|
||||||
- $serviceName: format('svc-{0}', randomName())
|
|
||||||
- $servicePort: $._findUnusedPort($applicationPort.port, $applicationPort.protocol)
|
|
||||||
- $serviceIp: $._createService($podId, $serviceName, $servicePort, $applicationPort)
|
|
||||||
Else:
|
Else:
|
||||||
- $servicesUsed: $servicesUsed + list($serviceName)
|
- $port: $._findUnusedPort($applicationPort.port, $applicationPort.protocol)
|
||||||
- $servicePort: $reuseEndpoint.port
|
- $record:
|
||||||
- $serviceIp: $._updateService($podId, $reuseEndpoint)
|
- assignedPort: $port
|
||||||
|
applicationPort: $applicationPort
|
||||||
|
- $serviceChanged: true
|
||||||
|
|
||||||
|
- $securityGroupIngress:
|
||||||
|
- ToPort: $port
|
||||||
|
FromPort: $port
|
||||||
|
IpProtocol: toLower($applicationPort.protocol)
|
||||||
|
External: $applicationPort.scope = public
|
||||||
|
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||||
|
|
||||||
|
- $servicePorts: $servicePorts + $record
|
||||||
|
|
||||||
|
- If: $serviceChanged
|
||||||
|
Then:
|
||||||
|
- $serviceIp: $._createOrUpdateService(
|
||||||
|
name => $serviceName,
|
||||||
|
ports => $servicePorts,
|
||||||
|
podId => $podId,
|
||||||
|
isNew => len($currentEndpoints) = 0
|
||||||
|
)
|
||||||
|
- $._updateEndpoints(
|
||||||
|
ports => $servicePorts,
|
||||||
|
applicationName => $applicationName,
|
||||||
|
podId => $podId,
|
||||||
|
serviceName => $serviceName,
|
||||||
|
serviceIp => $serviceIp
|
||||||
|
)
|
||||||
|
- $._environment.stack.push()
|
||||||
|
|
||||||
|
|
||||||
|
_createOrUpdateService:
|
||||||
|
Arguments:
|
||||||
|
- name:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
- ports:
|
||||||
|
Contract:
|
||||||
|
- assignedPort: $.int().notNull()
|
||||||
|
applicationPort: $.class(docker:ApplicationPort).notNull()
|
||||||
|
- podId:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
- isNew:
|
||||||
|
Contract: $.bool().notNull()
|
||||||
|
|
||||||
|
Body:
|
||||||
|
- $serviceDefinition:
|
||||||
|
apiVersion: v1beta3
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: $name
|
||||||
|
name: $name
|
||||||
|
spec:
|
||||||
|
ports: $ports.select(dict(
|
||||||
|
port => $.assignedPort,
|
||||||
|
targetPort => $.applicationPort.port,
|
||||||
|
protocol => $.applicationPort.protocol,
|
||||||
|
name => str($.assignedPort)
|
||||||
|
))
|
||||||
|
selector:
|
||||||
|
id: $podId
|
||||||
|
|
||||||
|
- If: $.gatewayCount = 0
|
||||||
|
Then:
|
||||||
|
- $serviceDefinition.spec.publicIPs: $.minionNodes.take($.nodeCount).select($.getIp())
|
||||||
|
|
||||||
|
- $resources: new(sys:Resources)
|
||||||
|
- $template: $resources.yaml('UpdateService.template').bind(dict(
|
||||||
|
serviceDefinition => $serviceDefinition,
|
||||||
|
isNew => $isNew
|
||||||
|
))
|
||||||
|
- Return: $.masterNode.instance.agent.call($template, $resources)
|
||||||
|
|
||||||
|
|
||||||
|
_updateEndpoints:
|
||||||
|
Arguments:
|
||||||
|
- ports:
|
||||||
|
Contract:
|
||||||
|
- assignedPort: $.int().notNull()
|
||||||
|
applicationPort: $.class(docker:ApplicationPort).notNull()
|
||||||
|
- applicationName:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
- podId:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
- serviceName:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
- serviceIp:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
Body:
|
||||||
|
- $.serviceEndpoints: $.serviceEndpoints.where($.applicationName != $applicationName or $.podId != $podId)
|
||||||
|
- For: port
|
||||||
|
In: $ports
|
||||||
|
Do:
|
||||||
- $newEndpoint:
|
- $newEndpoint:
|
||||||
port: $servicePort
|
port: $port.assignedPort
|
||||||
address: $serviceIp
|
address: $serviceIp
|
||||||
scope: internal
|
scope: internal
|
||||||
portScope: $applicationPort.scope
|
portScope: $port.applicationPort.scope
|
||||||
applicationName: $applicationName
|
applicationName: $applicationName
|
||||||
containerPort: $applicationPort.port
|
containerPort: $port.applicationPort.port
|
||||||
protocol: $applicationPort.protocol
|
protocol: $port.applicationPort.protocol
|
||||||
podId: $podId
|
podId: $podId
|
||||||
serviceName: $serviceName
|
serviceName: $serviceName
|
||||||
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
|
||||||
|
|
||||||
- If: $applicationPort.scope in list(public, cloud)
|
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
||||||
|
- If: $port.applicationPort.scope in list(public, cloud)
|
||||||
Then:
|
Then:
|
||||||
- If: $.gatewayCount > 0
|
- If: $.gatewayCount > 0
|
||||||
Then:
|
Then:
|
||||||
@ -248,129 +335,51 @@ Methods:
|
|||||||
- $newEndpoint.scope: cloud
|
- $newEndpoint.scope: cloud
|
||||||
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
||||||
|
|
||||||
- If: $t.instance.floatingIpAddress != null and $applicationPort.scope = public
|
- If: $t.instance.floatingIpAddress != null and $port.applicationPort.scope = public
|
||||||
Then:
|
Then:
|
||||||
- $newEndpoint.address: $t.instance.floatingIpAddress
|
- $newEndpoint.address: $t.instance.floatingIpAddress
|
||||||
- $newEndpoint.scope: public
|
- $newEndpoint.scope: public
|
||||||
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
||||||
- $newEndpoint:
|
- $newEndpoint:
|
||||||
port: $applicationPort.port
|
port: $port.applicationPort.port
|
||||||
address: '127.0.0.1'
|
address: '127.0.0.1'
|
||||||
scope: host
|
scope: host
|
||||||
portScope: $applicationPort.scope
|
portScope: $port.applicationPort.scope
|
||||||
containerPort: $applicationPort.port
|
containerPort: $port.applicationPort.port
|
||||||
protocol: $applicationPort.protocol
|
protocol: $port.applicationPort.protocol
|
||||||
applicationName: $applicationName
|
applicationName: $applicationName
|
||||||
podId: $podId
|
podId: $podId
|
||||||
serviceName: null
|
serviceName: null
|
||||||
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
|
||||||
|
|
||||||
- For: service
|
|
||||||
In: $applicationServices.keys()
|
|
||||||
Do:
|
|
||||||
- If: not $service in $servicesUsed
|
|
||||||
Then:
|
|
||||||
- $._deleteService($service)
|
|
||||||
- $._environment.stack.push()
|
|
||||||
|
|
||||||
|
_updateServicePublicIps:
|
||||||
_createService:
|
|
||||||
Arguments:
|
|
||||||
- podId:
|
|
||||||
Contract: $.string().notNull()
|
|
||||||
- serviceName:
|
|
||||||
Contract: $.string().notNull()
|
|
||||||
- servicePort:
|
|
||||||
Contract: $.int().notNull()
|
|
||||||
- applicationPort:
|
|
||||||
Contract: $.class(docker:ApplicationPort)
|
|
||||||
Body:
|
Body:
|
||||||
- $resources: new(sys:Resources)
|
- $prevNodeCount: $.getAttr(lastNodeCount, 0)
|
||||||
- $serviceDefinition: $._buildServiceDefinition(
|
- $prevGatewayCount: $.getAttr(lastGatewayCount, 0)
|
||||||
$serviceName,
|
|
||||||
$servicePort,
|
|
||||||
$applicationPort.protocol,
|
|
||||||
$applicationPort.port,
|
|
||||||
$podId,
|
|
||||||
$.gatewayCount = 0
|
|
||||||
)
|
|
||||||
- $template: $resources.yaml('UpdateService.template').bind(dict(
|
|
||||||
serviceDefinition => $serviceDefinition,
|
|
||||||
isNew => true
|
|
||||||
))
|
|
||||||
- $securityGroupIngress:
|
|
||||||
- ToPort: $servicePort
|
|
||||||
FromPort: $servicePort
|
|
||||||
IpProtocol: toLower($applicationPort.protocol)
|
|
||||||
External: $applicationPort.scope = public
|
|
||||||
|
|
||||||
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
|
||||||
|
|
||||||
- Return: $.masterNode.instance.agent.call($template, $resources)
|
|
||||||
|
|
||||||
|
|
||||||
_updateService:
|
|
||||||
Arguments:
|
|
||||||
- podId:
|
|
||||||
Contract: $.string().notNull()
|
|
||||||
- endpoint:
|
|
||||||
Contract:
|
|
||||||
port: $.int().notNull().check($ > 0)
|
|
||||||
address: $.string().notNull()
|
|
||||||
scope: $.string().notNull().check($ in list(public, cloud, internal, host))
|
|
||||||
containerPort: $.int().notNull().check($ > 0)
|
|
||||||
protocol: $.string().notNull().check($ in list(TCP, UDP))
|
|
||||||
applicationName: $.string().notNull()
|
|
||||||
podId: $.string().notNull()
|
|
||||||
serviceName: $.string()
|
|
||||||
|
|
||||||
Body:
|
|
||||||
- $resources: new(sys:Resources)
|
|
||||||
- $prevNodeCount: $.getAttr(lastNodeCount, 0-1) # 0-1 instead of -1 because YAQL 0.2 doesn't understand unary operators
|
|
||||||
- $prevGatewayCount: $.getAttr(lastGatewayCount, 0-1)
|
|
||||||
- $gatewayModeChanged: $prevGatewayCount != $.gatewayCount and $prevGatewayCount * $.gatewayCount = 0
|
- $gatewayModeChanged: $prevGatewayCount != $.gatewayCount and $prevGatewayCount * $.gatewayCount = 0
|
||||||
|
- If: $prevGatewayCount > 0 and $.gatewayCount > 0
|
||||||
- $serviceChanged: $endpoint.podId != $podId or
|
|
||||||
$endpoint.portScope in list(public, cloud) and (
|
|
||||||
$gatewayModeChanged or $.gatewayCount = 0 and $prevNodeCount != $.nodeCount)
|
|
||||||
- If: $serviceChanged
|
|
||||||
Then:
|
Then:
|
||||||
- $serviceDefinition: $._buildServiceDefinition(
|
- Return:
|
||||||
$endpoint.serviceName,
|
- If: $prevGatewayCount = 0 and $.gatewayCount = 0 and $prevNodeCount = $.nodeCount
|
||||||
$endpoint.port,
|
Then:
|
||||||
$endpoint.protocol,
|
- Return:
|
||||||
$endpoint.containerPort,
|
- $serviceNameMap: {}
|
||||||
$podId,
|
|
||||||
$.gatewayCount = 0
|
|
||||||
)
|
|
||||||
- $template: $resources.yaml('UpdateService.template').bind(dict(
|
|
||||||
serviceDefinition => $serviceDefinition,
|
|
||||||
isNew => false
|
|
||||||
))
|
|
||||||
- $serviceIp: $.masterNode.instance.agent.call($template, $resources)
|
|
||||||
Else:
|
|
||||||
- $serviceIp: $endpoint.address
|
|
||||||
- Return: $serviceIp
|
|
||||||
|
|
||||||
|
|
||||||
_updateEndpoints:
|
|
||||||
Body:
|
|
||||||
- For: endpoint
|
- For: endpoint
|
||||||
In: $.serviceEndpoints
|
In: $.serviceEndpoints
|
||||||
Do:
|
Do:
|
||||||
- $._updateService($endpoint.podId, $endpoint)
|
- $serviceName: $endpoint.serviceName
|
||||||
- $.setAttr(lastNodeCount, $.nodeCount)
|
- If: $serviceName != null
|
||||||
- $.setAttr(lastGatewayCount, $.gatewayCount)
|
Then:
|
||||||
|
- $serviceNameMap[$serviceName]: true
|
||||||
|
- $uniqueServiceNames: $serviceNameMap.keys()
|
||||||
_deleteService:
|
- If: len($uniqueServiceNames) > 0
|
||||||
Arguments:
|
Then:
|
||||||
serviceName:
|
- $publicIPs: $.minionNodes.take($.nodeCount).select($.getIp())
|
||||||
Contract: $.string().notNull()
|
|
||||||
Body:
|
|
||||||
- $resources: new(sys:Resources)
|
- $resources: new(sys:Resources)
|
||||||
- $template: $resources.yaml('DeleteService.template').bind(dict(
|
- $template: $resources.yaml('PatchServices.template').bind(dict(
|
||||||
serviceId => $service
|
services => $uniqueServiceNames,
|
||||||
|
publicIPs => $publicIPs
|
||||||
))
|
))
|
||||||
- $.masterNode.instance.agent.call($template, $resources)
|
- $.masterNode.instance.agent.call($template, $resources)
|
||||||
|
|
||||||
@ -382,7 +391,11 @@ Methods:
|
|||||||
- podId:
|
- podId:
|
||||||
Contract: $.string().notNull()
|
Contract: $.string().notNull()
|
||||||
Body:
|
Body:
|
||||||
- $._deleteService($applicationName, $podId)
|
- $resources: new(sys:Resources)
|
||||||
|
- $template: $resources.yaml('DeleteService.template').bind(dict(
|
||||||
|
serviceId => $service
|
||||||
|
))
|
||||||
|
- $.masterNode.instance.agent.call($template, $resources)
|
||||||
|
|
||||||
|
|
||||||
_findUnusedPort:
|
_findUnusedPort:
|
||||||
@ -413,36 +426,6 @@ Methods:
|
|||||||
- Return: len(list($.serviceEndpoints.where($.port = $port).where($.protocol = $protocol))) = 0
|
- Return: len(list($.serviceEndpoints.where($.port = $port).where($.protocol = $protocol))) = 0
|
||||||
|
|
||||||
|
|
||||||
_buildServiceDefinition:
|
|
||||||
Arguments:
|
|
||||||
- serviceName:
|
|
||||||
Contract: $.string().notNull()
|
|
||||||
- servicePort:
|
|
||||||
Contract: $.int().notNull()
|
|
||||||
- protocol:
|
|
||||||
Contract: $.string().notNull()
|
|
||||||
- containerPort:
|
|
||||||
Contract: $.int().notNull()
|
|
||||||
- podId:
|
|
||||||
Contract: $.string().notNull()
|
|
||||||
- withNodeIps:
|
|
||||||
Contract: $.bool().notNull()
|
|
||||||
Body:
|
|
||||||
- $result:
|
|
||||||
id: $serviceName
|
|
||||||
kind: Service
|
|
||||||
apiVersion: v1beta1
|
|
||||||
port: $servicePort
|
|
||||||
containerPort: $containerPort
|
|
||||||
protocol: $protocol
|
|
||||||
selector:
|
|
||||||
id: $podId
|
|
||||||
- If: $withNodeIps
|
|
||||||
Then:
|
|
||||||
- $result.publicIPs: $.minionNodes.take($.nodeCount).select($.getIp())
|
|
||||||
- Return: $result
|
|
||||||
|
|
||||||
|
|
||||||
scaleNodesUp:
|
scaleNodesUp:
|
||||||
Usage: Action
|
Usage: Action
|
||||||
Body:
|
Body:
|
||||||
|
@ -54,3 +54,7 @@ Methods:
|
|||||||
))
|
))
|
||||||
- $.instance.agent.call($template, $resources)
|
- $.instance.agent.call($template, $resources)
|
||||||
- $.setAttr(nodeConfigured, true)
|
- $.setAttr(nodeConfigured, true)
|
||||||
|
- $msg: 'Kubernetes API is now available at http://{0}:8080'
|
||||||
|
- $ip: coalesce($.instance.floatingIpAddress, $.getIp())
|
||||||
|
- $._environment.reporter.report($this, $msg.format($ip))
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Name: KubernetesMinionNode
|
|||||||
Extends: KubernetesNode
|
Extends: KubernetesNode
|
||||||
|
|
||||||
Properties:
|
Properties:
|
||||||
enableMonitoring:
|
exposeCAdvisor:
|
||||||
Contract: $.bool().notNull()
|
Contract: $.bool().notNull()
|
||||||
Default: false
|
Default: false
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ Methods:
|
|||||||
Body:
|
Body:
|
||||||
- If: not $.getAttr(instanceDeployed, false)
|
- If: not $.getAttr(instanceDeployed, false)
|
||||||
Then:
|
Then:
|
||||||
- $._environment.reporter.report($this, 'Creating Kubernetes Minion')
|
- $._environment.reporter.report($this, 'Creating Kubernetes Node {0}'.format($.instance.name))
|
||||||
- $.super($.deployInstance())
|
- $.super($.deployInstance())
|
||||||
- $.setAttr(instanceDeployed, true)
|
- $.setAttr(instanceDeployed, true)
|
||||||
|
|
||||||
@ -60,14 +60,11 @@ Methods:
|
|||||||
- $template: $resources.yaml('SetupFlannelNode.template')
|
- $template: $resources.yaml('SetupFlannelNode.template')
|
||||||
- $.instance.agent.call($template, $resources)
|
- $.instance.agent.call($template, $resources)
|
||||||
|
|
||||||
- If: $.enableMonitoring
|
|
||||||
Then:
|
|
||||||
- $._environment.reporter.report($this, 'Adding access to cAdvisor')
|
|
||||||
- $securityGroupIngress:
|
- $securityGroupIngress:
|
||||||
- ToPort: 4194
|
- ToPort: 4194
|
||||||
FromPort: 4194
|
FromPort: 4194
|
||||||
IpProtocol: tcp
|
IpProtocol: tcp
|
||||||
External: true
|
External: $.exposeCAdvisor
|
||||||
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||||
|
|
||||||
- $._environment.reporter.report($, 'Setup Kubernetes Minion on {0}'.format($.instance.name))
|
- $._environment.reporter.report($, 'Setup Kubernetes Minion on {0}'.format($.instance.name))
|
||||||
@ -75,17 +72,40 @@ Methods:
|
|||||||
name => $.instance.name,
|
name => $.instance.name,
|
||||||
ip => $.getIp(),
|
ip => $.getIp(),
|
||||||
masterIp => $._cluster.masterNode.getIp(),
|
masterIp => $._cluster.masterNode.getIp(),
|
||||||
enableMonitoring => $.enableMonitoring,
|
|
||||||
dockerRegistry => $._cluster.dockerRegistry
|
dockerRegistry => $._cluster.dockerRegistry
|
||||||
))
|
))
|
||||||
- $.instance.agent.call($template, $resources)
|
- $.instance.agent.call($template, $resources)
|
||||||
|
- $._registerNode()
|
||||||
|
- $.setAttr(nodeConfigured, true)
|
||||||
|
- $msg: 'cAdvisor monitoring for Node {0} is now available at http://{1}:4194'
|
||||||
|
- $ip: $.getIp()
|
||||||
|
- If: $.exposeCAdvisor
|
||||||
|
Then:
|
||||||
|
- $ip: coalesce($.instance.floatingIpAddress, $.getIp())
|
||||||
|
- $._environment.reporter.report($this, $msg.format($.instance.name, $ip))
|
||||||
|
|
||||||
|
|
||||||
|
_registerNode:
|
||||||
|
Body:
|
||||||
|
- $nodeDefinition:
|
||||||
|
kind: Node
|
||||||
|
apiVersion: v1beta3
|
||||||
|
metadata:
|
||||||
|
name: $.getIp()
|
||||||
|
labels:
|
||||||
|
name: $.instance.name
|
||||||
|
spec:
|
||||||
|
externalID: $.id()
|
||||||
|
status:
|
||||||
|
capacity:
|
||||||
|
cpu: 200
|
||||||
|
memory: 4145438720
|
||||||
|
|
||||||
|
- $resources: new(sys:Resources)
|
||||||
- $template: $resources.yaml('KubeRegisterNode.template').bind(dict(
|
- $template: $resources.yaml('KubeRegisterNode.template').bind(dict(
|
||||||
name => $.instance.name,
|
nodeDefinition => $nodeDefinition
|
||||||
nodeId => $.getIp()
|
|
||||||
))
|
))
|
||||||
- $._cluster.masterNode.instance.agent.call($template, $resources)
|
- $._cluster.masterNode.instance.agent.call($template, $resources)
|
||||||
- $.setAttr(nodeConfigured, true)
|
|
||||||
|
|
||||||
|
|
||||||
removeFromCluster:
|
removeFromCluster:
|
||||||
|
@ -6,13 +6,12 @@ Parameters:
|
|||||||
name: $name
|
name: $name
|
||||||
ip: $ip
|
ip: $ip
|
||||||
masterIp: $masterIp
|
masterIp: $masterIp
|
||||||
enableMonitoring: $enableMonitoring
|
|
||||||
dockerRegistry: $dockerRegistry
|
dockerRegistry: $dockerRegistry
|
||||||
|
|
||||||
Body: |
|
Body: |
|
||||||
if args.dockerRegistry:
|
if args.dockerRegistry:
|
||||||
setupRegistry(args.dockerRegistry)
|
setupRegistry(args.dockerRegistry)
|
||||||
setup('{0} {1} {2} {3}'.format(args.name, args.ip, args.masterIp, args.enableMonitoring))
|
setup('{0} {1} {2}'.format(args.name, args.ip, args.masterIp))
|
||||||
|
|
||||||
Scripts:
|
Scripts:
|
||||||
setup:
|
setup:
|
||||||
@ -26,7 +25,6 @@ Scripts:
|
|||||||
- init_conf/kube-proxy.conf
|
- init_conf/kube-proxy.conf
|
||||||
- initd_scripts/kubelet
|
- initd_scripts/kubelet
|
||||||
- initd_scripts/kube-proxy
|
- initd_scripts/kube-proxy
|
||||||
- cadvisor.manifest
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
captureStdout: true
|
captureStdout: true
|
||||||
|
@ -3,19 +3,23 @@ Version: 1.0.0
|
|||||||
Name: Register Kubernetes Node
|
Name: Register Kubernetes Node
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
name: $name
|
nodeDefinition: $nodeDefinition
|
||||||
nodeId: $nodeId
|
|
||||||
|
|
||||||
Body: |
|
Body: |
|
||||||
return register('{0} {1}'.format(args.name, args.nodeId)).stdout
|
import json
|
||||||
|
import uuid
|
||||||
|
fileName = '/var/run/murano-kubernetes/' + str(uuid.uuid4()) + '.json'
|
||||||
|
with open(fileName, 'w') as f:
|
||||||
|
json.dump(args.nodeDefinition, f)
|
||||||
|
|
||||||
|
return register(fileName).stdout
|
||||||
|
|
||||||
Scripts:
|
Scripts:
|
||||||
register:
|
register:
|
||||||
Type: Application
|
Type: Application
|
||||||
Version: 1.0.0
|
Version: 1.0.0
|
||||||
EntryPoint: kube-add-node.sh
|
EntryPoint: kube-add-node.sh
|
||||||
Files:
|
Files: []
|
||||||
- minion-node.json
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
captureStdout: true
|
captureStdout: true
|
||||||
|
@ -13,8 +13,8 @@ Body: |
|
|||||||
with open(fileName, 'w') as f:
|
with open(fileName, 'w') as f:
|
||||||
json.dump(args.serviceDefinition, f)
|
json.dump(args.serviceDefinition, f)
|
||||||
|
|
||||||
updateService('{0} {1} {2} {3}'.format(args.isNew, args.serviceDefinition['id'], args.serviceDefinition['kind'], fileName))
|
updateService('{0} {1} {2}'.format(args.isNew, args.serviceDefinition['metadata']['name'], fileName))
|
||||||
return getServiceIp(args.serviceDefinition['id']).stdout
|
return getServiceIp(args.serviceDefinition['metadata']['name']).stdout
|
||||||
|
|
||||||
Scripts:
|
Scripts:
|
||||||
updateService:
|
updateService:
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
version: v1beta2
|
|
||||||
id: cadvisor-agent
|
|
||||||
containers:
|
|
||||||
- name: cadvisor
|
|
||||||
image: google/cadvisor:latest
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 8080
|
|
||||||
hostPort: 4194
|
|
||||||
volumeMounts:
|
|
||||||
- name: varrun
|
|
||||||
mountPath: /var/run
|
|
||||||
readOnly: false
|
|
||||||
- name: varlibdocker
|
|
||||||
mountPath: /var/lib/docker
|
|
||||||
readOnly: true
|
|
||||||
- name: cgroups
|
|
||||||
mountPath: /sys/fs/cgroup
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: varrun
|
|
||||||
source:
|
|
||||||
hostDir:
|
|
||||||
path: /var/run
|
|
||||||
- name: varlibdocker
|
|
||||||
source:
|
|
||||||
hostDir:
|
|
||||||
path: /var/lib/docker
|
|
||||||
- name: cgroups
|
|
||||||
source:
|
|
||||||
hostDir:
|
|
||||||
path: /sys/fs/cgroup
|
|
@ -4,7 +4,6 @@
|
|||||||
# KUBE_PROXY="/opt/bin/kube-proxy"
|
# KUBE_PROXY="/opt/bin/kube-proxy"
|
||||||
|
|
||||||
# Use KUBE_PROXY_OPTS to modify the start/restart options
|
# Use KUBE_PROXY_OPTS to modify the start/restart options
|
||||||
KUBE_PROXY_OPTS="--etcd_servers=http://127.0.0.1:4001 \
|
KUBE_PROXY_OPTS="--logtostderr=false --master=http://%%MASTER_IP%%:8080 --log_dir=/var/log/kubernetes"
|
||||||
--logtostderr=false --master=http://%%MASTER_IP%%:8080 --log_dir=/var/log/kubernetes"
|
|
||||||
|
|
||||||
# Add more envionrment settings used by kube-apiserver here
|
# Add more envionrment settings used by kube-apiserver here
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
/opt/bin/kubectl get service $1 -t '{{.portalIP}}' -o template
|
/opt/bin/kubectl get service $1 -t '{{.spec.portalIP}}' -o template
|
@ -5,15 +5,16 @@ defaults
|
|||||||
contimeout 5000
|
contimeout 5000
|
||||||
clitimeout 50000
|
clitimeout 50000
|
||||||
srvtimeout 50000
|
srvtimeout 50000
|
||||||
|
|
||||||
{{range $svc := ls "/registry/services/endpoints/default"}}
|
{{range $svc := ls "/registry/services/endpoints/default"}}
|
||||||
{{$se := printf "/registry/services/endpoints/default/%s" $svc }}{{$ss := printf "/registry/services/specs/default/%s" $svc }}
|
{{$se := printf "/registry/services/endpoints/default/%s" $svc }}
|
||||||
{{$seKey := get $se}}{{$ssKey := get $ss}}{{$seJson := json $seKey.Value}}{{$ssJson := json $ssKey.Value}}{{$baseSvc := base $svc}}
|
{{$ss := printf "/registry/services/specs/default/%s" $svc }}
|
||||||
{{if and (ne "kubernetes" $baseSvc) (ne "kubernetes-ro" $baseSvc)}}
|
{{$seKey := get $se}}{{$ssKey := get $ss}}{{$seJson := json $seKey.Value}}
|
||||||
listen {{$baseSvc}} 0.0.0.0:{{$ssJson.port}}
|
{{$ssJson := json $ssKey.Value}}{{$baseSvc := base $svc}}
|
||||||
|
{{if and (ne "kubernetes" $baseSvc) (ne "kubernetes-ro" $baseSvc)}}{{range $port := $ssJson.spec.ports}}
|
||||||
|
listen {{$baseSvc}}-{{$port.port}} 0.0.0.0:{{$port.port}}
|
||||||
mode tcp
|
mode tcp
|
||||||
balance leastconn
|
balance leastconn
|
||||||
{{range $index, $endpoint := $seJson.endpoints}}
|
{{range $subset := $seJson.subsets}}{{range $index, $endpoint := $subset.addresses}}
|
||||||
server svr{{$index}} {{$endpoint}}{{end}}
|
server svr{{$index}} {{$endpoint.IP}}:{{$port.targetPort}}{{end}}{{end}}
|
||||||
|
|
||||||
{{end}}{{end}}
|
{{end}}{{end}}{{end}}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# $1 - NAME
|
# $1 - file path
|
||||||
# $2 - IP
|
|
||||||
#
|
|
||||||
|
|
||||||
sed -i.bkp "s/%%NAME%%/$1/g" minion-node.json
|
/opt/bin/kubectl create -f $1
|
||||||
sed -i.bkp "s/%%IP%%/$2/g" minion-node.json
|
|
||||||
|
|
||||||
/opt/bin/kubectl create -f minion-node.json
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# $1 - NAME
|
# $1 - NAME
|
||||||
# $2 - IP
|
# $2 - IP
|
||||||
# $3 - MASTER_IP
|
# $3 - MASTER_IP
|
||||||
# $4 - IS_CA_ENABLED
|
|
||||||
|
|
||||||
mkdir /var/log/kubernetes
|
mkdir /var/log/kubernetes
|
||||||
mkdir -p /var/run/murano-kubernetes
|
mkdir -p /var/run/murano-kubernetes
|
||||||
@ -22,16 +21,6 @@ cp initd_scripts/kube-proxy /etc/init.d/
|
|||||||
cp -f default_scripts/kube-proxy /etc/default
|
cp -f default_scripts/kube-proxy /etc/default
|
||||||
cp -f default_scripts/kubelet /etc/default/
|
cp -f default_scripts/kubelet /etc/default/
|
||||||
|
|
||||||
if [ "$4" == "True" ]; then
|
|
||||||
#Create directory for manifests used by kubelet
|
|
||||||
mkdir /etc/kubernetes
|
|
||||||
mkdir /etc/kubernetes/manifests
|
|
||||||
cp -f cadvisor.manifest /etc/kubernetes/manifests
|
|
||||||
#Add path to kubelet parameters
|
|
||||||
sed -i 's/kubernetes"/kubernetes \\/g' /etc/default/kubelet
|
|
||||||
sed -i '/--log_dir*/a --config=/etc/kubernetes/manifests"' /etc/default/kubelet
|
|
||||||
fi
|
|
||||||
|
|
||||||
service kubelet start
|
service kubelet start
|
||||||
service kube-proxy start
|
service kube-proxy start
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "%%IP%%",
|
|
||||||
"kind": "Minion",
|
|
||||||
"apiVersion": "v1beta1",
|
|
||||||
"resources": {
|
|
||||||
"capacity": {
|
|
||||||
"cpu": 200,
|
|
||||||
"memory": 4145438720
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"labels": {
|
|
||||||
"name": "%%NAME%%"
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,10 +5,9 @@
|
|||||||
DEFINITION_DIR=/var/run/murano-kubernetes
|
DEFINITION_DIR=/var/run/murano-kubernetes
|
||||||
mkdir -p $DEFINITION_DIR
|
mkdir -p $DEFINITION_DIR
|
||||||
serviceId=$2
|
serviceId=$2
|
||||||
kind=$3
|
fileName=$3
|
||||||
fileName=$4
|
|
||||||
|
|
||||||
echo "$serviceId $kind $fileName" >> $DEFINITION_DIR/elements.list
|
echo "$serviceId Service $fileName" >> $DEFINITION_DIR/elements.list
|
||||||
|
|
||||||
if [ "$1" == "True" ]; then
|
if [ "$1" == "True" ]; then
|
||||||
echo "Creating a new Service" >> /tmp/murano-kube.log
|
echo "Creating a new Service" >> /tmp/murano-kube.log
|
||||||
|
@ -24,7 +24,7 @@ Templates:
|
|||||||
image: 'ubuntu14.04-x64-kubernetes'
|
image: 'ubuntu14.04-x64-kubernetes'
|
||||||
assignFloatingIp: $.appConfiguration.assignFloatingIP
|
assignFloatingIp: $.appConfiguration.assignFloatingIP
|
||||||
keyname: $.instanceConfiguration.keyPair
|
keyname: $.instanceConfiguration.keyPair
|
||||||
enableMonitoring: $.appConfiguration.enableMonitoring
|
exposeCAdvisor: $.appConfiguration.exposeCAdvisor
|
||||||
|
|
||||||
|
|
||||||
gatewayNode:
|
gatewayNode:
|
||||||
@ -97,13 +97,13 @@ Forms:
|
|||||||
errorMessages:
|
errorMessages:
|
||||||
invalid: Just letters, numbers, underscores, sharps and hyphens are allowed.
|
invalid: Just letters, numbers, underscores, sharps and hyphens are allowed.
|
||||||
label: Kubernetes node hostname pattern
|
label: Kubernetes node hostname pattern
|
||||||
- name: enableMonitoring
|
- name: exposeCAdvisor
|
||||||
type: boolean
|
type: boolean
|
||||||
initial: true
|
initial: true
|
||||||
required: false
|
required: false
|
||||||
label: Enable cAdvisor monitoring
|
label: Expose cAdvisor UI
|
||||||
description: >-
|
description: >-
|
||||||
Enable cAdvisor monitoring
|
Opens external access to cAdvisor interface
|
||||||
- name: gatewayCount
|
- name: gatewayCount
|
||||||
type: integer
|
type: integer
|
||||||
label: Initial/current number of gateway nodes
|
label: Initial/current number of gateway nodes
|
||||||
|
@ -35,16 +35,14 @@ Methods:
|
|||||||
- If: $podDefinition = null
|
- If: $podDefinition = null
|
||||||
Then:
|
Then:
|
||||||
- $podDefinition:
|
- $podDefinition:
|
||||||
id: $podName
|
apiVersion: v1beta3
|
||||||
kind: Pod
|
kind: Pod
|
||||||
apiVersion: v1beta1
|
metadata:
|
||||||
desiredState:
|
name: $podName
|
||||||
manifest:
|
labels: $._getPodLabels($podName)
|
||||||
version: v1beta1
|
spec:
|
||||||
id: $podName
|
|
||||||
containers: []
|
containers: []
|
||||||
volumes: []
|
volumes: []
|
||||||
labels: $._getPodLabels($podName)
|
|
||||||
|
|
||||||
- $.setAttr(lastPodDeployed, $podDefinition)
|
- $.setAttr(lastPodDeployed, $podDefinition)
|
||||||
- $._podDefinition: $podDefinition
|
- $._podDefinition: $podDefinition
|
||||||
@ -81,23 +79,23 @@ Methods:
|
|||||||
- $containerDef:
|
- $containerDef:
|
||||||
name: toLower($container.name)
|
name: toLower($container.name)
|
||||||
image: $container.image
|
image: $container.image
|
||||||
command: $container.commands
|
args: $container.commands
|
||||||
ports: $container.ports.select($this._getPortDefinition($))
|
ports: $container.ports.select($this._getPortDefinition($))
|
||||||
volumeMounts: $container.volumes.keys().select(dict(name => $this._generateVolumeName($container.volumes.get($)), mountPath => $))
|
volumeMounts: $container.volumes.keys().select(dict(name => $this._generateVolumeName($container.volumes.get($)), mountPath => $))
|
||||||
env: $container.env.keys().select(dict(key => $, value => $container.env.get($)))
|
env: $container.env.keys().select(dict(key => $, value => $container.env.get($)))
|
||||||
|
|
||||||
- $newVolumes: $container.volumes.values().where(not $this._generateVolumeName($) in $this._podDefinition.desiredState.volumes.name).
|
- $newVolumes: $container.volumes.values().where(not $this._generateVolumeName($) in $this._podDefinition.spec.volumes.name).
|
||||||
select($this._buildVolumeEntry($))
|
select($this._buildVolumeEntry($))
|
||||||
|
|
||||||
- $diff:
|
- $diff:
|
||||||
desiredState:
|
- $diff:
|
||||||
manifest:
|
spec:
|
||||||
containers: [$containerDef]
|
containers: [$containerDef]
|
||||||
volumes: $newVolumes
|
volumes: $newVolumes
|
||||||
- $._podDefinition: $._podDefinition.mergeWith($diff)
|
- $._podDefinition: $._podDefinition.mergeWith($diff)
|
||||||
- $.deploy()
|
- $.deploy()
|
||||||
- $._environment.reporter.report($, 'Creating services for Pod {0}'.format($.name))
|
- $._environment.reporter.report($, 'Creating services for Pod {0}'.format($.name))
|
||||||
- $.kubernetesCluster.createServices(
|
- $.kubernetesCluster.createService(
|
||||||
applicationName => $container.name,
|
applicationName => $container.name,
|
||||||
applicationPorts => $container.ports,
|
applicationPorts => $container.ports,
|
||||||
podId => $podName)
|
podId => $podName)
|
||||||
@ -153,14 +151,14 @@ Methods:
|
|||||||
- name:
|
- name:
|
||||||
Contract: $.string().notNull()
|
Contract: $.string().notNull()
|
||||||
Body:
|
Body:
|
||||||
- $lenBefore: len($._podDefinition.desiredState.manifest.containers) + len($._podDefinition.desiredState.manifest.volumes)
|
- $lenBefore: len($._podDefinition.spec.containers) + len($._podDefinition.spec.volumes)
|
||||||
- $newContainers: $._podDefinition.desiredState.manifest.containers.where($.name != $name)
|
- $newContainers: $._podDefinition.spec.containers.where($.name != $name)
|
||||||
- $newVolumes: $._podDefinition.desiredState.manifest.volumes.where(
|
- $newVolumes: $._podDefinition.spec.volumes.where(
|
||||||
$.name in $._podDefinition.desiredState.manifest.containers.volumeMounts.name)
|
$.name in $._podDefinition.spec.containers.volumeMounts.name)
|
||||||
- If: len($newContainers) + len($newVolumes) != $lenBefore
|
- If: len($newContainers) + len($newVolumes) != $lenBefore
|
||||||
Then:
|
Then:
|
||||||
- $._podDefinition.desiredState.manifest.containers: $newContainers
|
- $._podDefinition.spec.containers: $newContainers
|
||||||
- $._podDefinition.desiredState.manifest.volumes: $newVolumes
|
- $._podDefinition.spec.volumes: $newVolumes
|
||||||
|
|
||||||
|
|
||||||
deleteContainer:
|
deleteContainer:
|
||||||
@ -190,7 +188,7 @@ Methods:
|
|||||||
|
|
||||||
- $podDefinition: $._podDefinition
|
- $podDefinition: $._podDefinition
|
||||||
- $replicas: $.replicas
|
- $replicas: $.replicas
|
||||||
- If: len($podDefinition.desiredState.manifest.containers) = 0
|
- If: len($podDefinition.spec.containers) = 0
|
||||||
Then:
|
Then:
|
||||||
- $replicas: 0
|
- $replicas: 0
|
||||||
- $.setAttr(lastReplicas, $replicas)
|
- $.setAttr(lastReplicas, $replicas)
|
||||||
@ -205,10 +203,10 @@ Methods:
|
|||||||
- If: $replicas = 0 and $prevReplicas > 0
|
- If: $replicas = 0 and $prevReplicas > 0
|
||||||
Then:
|
Then:
|
||||||
- $.kubernetesCluster.deleteReplicationController($._getReplicationControllerId())
|
- $.kubernetesCluster.deleteReplicationController($._getReplicationControllerId())
|
||||||
- If: $prevPod != $podDefinition
|
- If: $prevPod != $podDefinition and len($prevPod.spec.containers) > 0
|
||||||
Then:
|
Then:
|
||||||
- $.kubernetesCluster.deletePods(dict(id => $._getPodName()))
|
- $.kubernetesCluster.deletePods(dict(id => $._getPodName()))
|
||||||
- If: $.replicas = 0 and len($podDefinition.desiredState.manifest.containers) > 0
|
- If: $.replicas = 0 and len($podDefinition.spec.containers) > 0
|
||||||
Then:
|
Then:
|
||||||
- $.kubernetesCluster.createPod(definition => $podDefinition, isNew => true)
|
- $.kubernetesCluster.createPod(definition => $podDefinition, isNew => true)
|
||||||
|
|
||||||
@ -222,16 +220,19 @@ Methods:
|
|||||||
Contract: {}
|
Contract: {}
|
||||||
Body:
|
Body:
|
||||||
Return:
|
Return:
|
||||||
id: $._getReplicationControllerId()
|
apiVersion: v1beta3
|
||||||
kind: ReplicationController
|
kind: ReplicationController
|
||||||
apiVersion: v1beta1
|
metadata:
|
||||||
desiredState:
|
name: $._getReplicationControllerId()
|
||||||
|
labels: $podDefinition.metadata.labels
|
||||||
|
spec:
|
||||||
replicas: $.replicas
|
replicas: $.replicas
|
||||||
replicaSelector:
|
selector:
|
||||||
id: $._getPodName()
|
id: $._getPodName()
|
||||||
podTemplate:
|
template:
|
||||||
desiredState: $podDefinition.desiredState
|
metadata:
|
||||||
labels: $podDefinition.labels
|
labels: $podDefinition.metadata.labels
|
||||||
|
spec: $podDefinition.spec
|
||||||
|
|
||||||
|
|
||||||
_getReplicationControllerId:
|
_getReplicationControllerId:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user