Merge "Update for changes in k8s 0.15"

This commit is contained in:
Jenkins 2015-04-21 14:17:48 +00:00 committed by Gerrit Code Review
commit e4645044e1
16 changed files with 299 additions and 352 deletions

View File

@ -91,23 +91,30 @@ Methods:
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress) - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
- $.setAttr(deployed, true) - $.setAttr(deployed, true)
- $._environment.reporter.report($this, 'Setting up Kubernetes cluster') - $prevNodeCount: $.getAttr(lastNodeCount, 0)
- Parallel: - $prevGatewayCount: $.getAttr(lastGatewayCount, 0)
- Do: $.masterNode.deployInstance()
- Do: $.minionNodes.take($.nodeCount).pselect($.deployInstance())
- Do: $.gatewayNodes.take($.gatewayCount).pselect($.deployInstance())
- $.masterNode.setupEtcd() - If: $prevNodeCount != $.nodeCount or $prevGatewayCount != $.gatewayCount
- $.minionNodes.take($.nodeCount).select($.setupEtcd()) Then:
- $.gatewayNodes.take($.gatewayCount).select($.setupEtcd()) - $._environment.reporter.report($this, 'Setting up Kubernetes cluster')
- Parallel:
- Do: $.masterNode.deployInstance()
- Do: $.minionNodes.take($.nodeCount).pselect($.deployInstance())
- Do: $.gatewayNodes.take($.gatewayCount).pselect($.deployInstance())
- $.masterNode.setupNode() - $.masterNode.setupEtcd()
- Parallel: - $.minionNodes.take($.nodeCount).select($.setupEtcd())
- Do: $.minionNodes.take($.nodeCount).pselect($.setupNode()) - $.gatewayNodes.take($.gatewayCount).select($.setupEtcd())
- Do: $.minionNodes.skip($.nodeCount).pselect($.removeFromCluster())
- Do: $.gatewayNodes.take($.gatewayCount).pselect($.setupNode()) - $.masterNode.setupNode()
- $._updateEndpoints() - Parallel:
- $._environment.reporter.report($this, 'Kubernetes cluster is up and running') - Do: $.minionNodes.take($.nodeCount).pselect($.setupNode())
- Do: $.minionNodes.skip($.nodeCount).pselect($.removeFromCluster())
- Do: $.gatewayNodes.take($.gatewayCount).pselect($.setupNode())
- $._updateServicePublicIps()
- $.setAttr(lastNodeCount, $.nodeCount)
- $.setAttr(lastGatewayCount, $.gatewayCount)
- $._environment.reporter.report($this, 'Kubernetes cluster is up and running')
getIp: getIp:
@ -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,197 +189,199 @@ 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() Else:
Do: - $port: $._findUnusedPort($applicationPort.port, $applicationPort.protocol)
- $endpoint: $applicationServices.get($service) - $record:
- If: $endpoint.containerPort = $applicationPort.port and $endpoint.protocol = $applicationPort.protocol - assignedPort: $port
Then: applicationPort: $applicationPort
- $serviceName: $service - $serviceChanged: true
- $reuseEndpoint: $endpoint
- Break:
- If: $serviceName = null - $securityGroupIngress:
Then: - ToPort: $port
- $serviceName: format('svc-{0}', randomName()) FromPort: $port
- $servicePort: $._findUnusedPort($applicationPort.port, $applicationPort.protocol) IpProtocol: toLower($applicationPort.protocol)
- $serviceIp: $._createService($podId, $serviceName, $servicePort, $applicationPort) External: $applicationPort.scope = public
Else: - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
- $servicesUsed: $servicesUsed + list($serviceName)
- $servicePort: $reuseEndpoint.port
- $serviceIp: $._updateService($podId, $reuseEndpoint)
- $newEndpoint: - $servicePorts: $servicePorts + $record
port: $servicePort
address: $serviceIp
scope: internal
portScope: $applicationPort.scope
applicationName: $applicationName
containerPort: $applicationPort.port
protocol: $applicationPort.protocol
podId: $podId
serviceName: $serviceName
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
- If: $applicationPort.scope in list(public, cloud) - If: $serviceChanged
Then: Then:
- If: $.gatewayCount > 0 - $serviceIp: $._createOrUpdateService(
Then: name => $serviceName,
- $nodes: $.gatewayNodes.take($.gatewayCount) ports => $servicePorts,
Else: podId => $podId,
- $nodes: $.minionNodes.take($.nodeCount) isNew => len($currentEndpoints) = 0
)
- $._updateEndpoints(
ports => $servicePorts,
applicationName => $applicationName,
podId => $podId,
serviceName => $serviceName,
serviceIp => $serviceIp
)
- $._environment.stack.push()
- For: t
In: $nodes
Do:
- $newEndpoint.address: $t.getIp()
- $newEndpoint.scope: cloud
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
- If: $t.instance.floatingIpAddress != null and $applicationPort.scope = public _createOrUpdateService:
Then: Arguments:
- $newEndpoint.address: $t.instance.floatingIpAddress - name:
- $newEndpoint.scope: public Contract: $.string().notNull()
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint) - 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: $applicationPort.port port: $port.assignedPort
address: $serviceIp
scope: internal
portScope: $port.applicationPort.scope
applicationName: $applicationName
containerPort: $port.applicationPort.port
protocol: $port.applicationPort.protocol
podId: $podId
serviceName: $serviceName
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
- If: $port.applicationPort.scope in list(public, cloud)
Then:
- If: $.gatewayCount > 0
Then:
- $nodes: $.gatewayNodes.take($.gatewayCount)
Else:
- $nodes: $.minionNodes.take($.nodeCount)
- For: t
In: $nodes
Do:
- $newEndpoint.address: $t.getIp()
- $newEndpoint.scope: cloud
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
- If: $t.instance.floatingIpAddress != null and $port.applicationPort.scope = public
Then:
- $newEndpoint.address: $t.instance.floatingIpAddress
- $newEndpoint.scope: public
- $.serviceEndpoints: $.serviceEndpoints + list($newEndpoint)
- $newEndpoint:
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() - $resources: new(sys:Resources)
Body: - $template: $resources.yaml('PatchServices.template').bind(dict(
- $resources: new(sys:Resources) services => $uniqueServiceNames,
- $template: $resources.yaml('DeleteService.template').bind(dict( publicIPs => $publicIPs
serviceId => $service ))
)) - $.masterNode.instance.agent.call($template, $resources)
- $.masterNode.instance.agent.call($template, $resources)
deleteService: deleteService:
@ -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:

View File

@ -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))

View File

@ -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,32 +60,52 @@ Methods:
- $template: $resources.yaml('SetupFlannelNode.template') - $template: $resources.yaml('SetupFlannelNode.template')
- $.instance.agent.call($template, $resources) - $.instance.agent.call($template, $resources)
- If: $.enableMonitoring - $securityGroupIngress:
Then: - ToPort: 4194
- $._environment.reporter.report($this, 'Adding access to cAdvisor') FromPort: 4194
- $securityGroupIngress: IpProtocol: tcp
- ToPort: 4194 External: $.exposeCAdvisor
FromPort: 4194 - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
IpProtocol: tcp
External: true
- $._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))
- $template: $resources.yaml('KubeMinionSetup.template').bind(dict( - $template: $resources.yaml('KubeMinionSetup.template').bind(dict(
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()
- $template: $resources.yaml('KubeRegisterNode.template').bind(dict(
name => $.instance.name,
nodeId => $.getIp()
))
- $._cluster.masterNode.instance.agent.call($template, $resources)
- $.setAttr(nodeConfigured, true) - $.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(
nodeDefinition => $nodeDefinition
))
- $._cluster.masterNode.instance.agent.call($template, $resources)
removeFromCluster: removeFromCluster:

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}}

View File

@ -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

View File

@ -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

View File

@ -1,14 +0,0 @@
{
"id": "%%IP%%",
"kind": "Minion",
"apiVersion": "v1beta1",
"resources": {
"capacity": {
"cpu": 200,
"memory": 4145438720
}
},
"labels": {
"name": "%%NAME%%"
}
}

View File

@ -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

View File

@ -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

View File

@ -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: