Add basic heat support

Change-Id: Iabab0770fd03fa11845ac175b13886cdfa8a42d8
This commit is contained in:
Mohammed Naser 2020-04-25 09:10:58 -04:00 committed by okozachenko
parent 97501c4460
commit f2bf41d3e7
15 changed files with 342 additions and 19 deletions

View File

@ -1,6 +1,9 @@
images:
docker build images/horizon -t vexxhost/horizon:latest
docker build images/ceilometer --target ceilometer-agent-notification -t vexxhost/ceilometer-agent-notification:latest
docker build images/heat --target heat-api -t vexxhost/heat-api:latest
docker build images/heat --target heat-api-cfn -t vexxhost/heat-api-cfn:latest
docker build images/heat --target heat-engine -t vexxhost/heat-engine:latest
docker build images/mcrouter -t vexxhost/mcrouter:latest
docker build images/mcrouter-exporter -t vexxhost/mcrouter-exporter:latest
docker build images/memcached -t vexxhost/memcached:latest

View File

@ -0,0 +1,24 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: heats.orchestration.openstack.org
spec:
group: orchestration.openstack.org
names:
kind: Heat
listKind: HeatList
plural: heats
singular: heat
scope: Namespaced
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@ -131,6 +131,26 @@ rules:
- get
- patch
- update
- apiGroups:
- orchestration.openstack.org
resources:
- heats
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- orchestration.openstack.org
resources:
- heats/status
verbs:
- get
- patch
- update
- apiGroups:
- dashboard.openstack.org
resources:

View File

@ -29,6 +29,8 @@ spec:
args:
- run
- -m
- openstack_operator.heat
- -m
- openstack_operator.horizon
- -m
- openstack_operator.keystone

View File

@ -0,0 +1,7 @@
---
apiVersion: orchestration.openstack.org/v1alpha1
kind: Heat
metadata:
name: sample
spec:
configDir: /etc/heat

View File

@ -51,9 +51,8 @@ for image in images:
continue
if len(line.value) >= 3 and line.value[1].lower() != 'as':
continue
if line.value[0] != image:
continue
targets.append(line.value[2])
if len(line.value) >= 3 and image in line.value[2]:
targets.append(line.value[2])
# Update images if we have more than 1 target
if targets:

37
images/heat/Dockerfile Normal file
View File

@ -0,0 +1,37 @@
# Copyright (c) 2020 VEXXHOST, Inc.
#
# 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.
FROM docker.io/opendevorg/python-builder as builder
COPY bindep.txt /tmp/src/bindep.txt
RUN assemble openstack-heat==13.0.1 python-memcached
FROM docker.io/opendevorg/uwsgi-base AS heat-api-base
COPY --from=builder /output/ /output
RUN /output/install-from-bindep
RUN ln -s /usr/local/etc/heat /etc/heat
FROM heat-api-base AS heat-api
EXPOSE 8004
ENV UWSGI_HTTP_SOCKET=:8004 UWSGI_WSGI_FILE=/usr/local/bin/heat-wsgi-api
FROM heat-api-base AS heat-api-cfn
EXPOSE 8000
ENV UWSGI_HTTP_SOCKET=:8000 UWSGI_WSGI_FILE=/usr/local/bin/heat-wsgi-api-cfn
FROM docker.io/opendevorg/python-base AS heat-engine
COPY --from=builder /output/ /output
RUN /output/install-from-bindep
RUN ln -s /usr/local/etc/heat /etc/heat
CMD ["/usr/local/bin/heat-engine"]

2
images/heat/bindep.txt Normal file
View File

@ -0,0 +1,2 @@
gcc [compile]
libc-dev [compile]

View File

@ -0,0 +1,43 @@
# Copyright 2020 VEXXHOST, Inc.
#
# 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.
"""Heat Operator
This module maintains the operator for Heat, it takes care of creating
the appropriate deployments, an instance of Memcache, RabbitMQ and a database
server for the installation.
"""
import kopf
from openstack_operator import utils
@kopf.on.resume('orchestration.openstack.org', 'v1alpha1', 'heats')
@kopf.on.create('orchestration.openstack.org', 'v1alpha1', 'heats')
def create_or_resume(name, spec, **_):
"""Create and re-sync any Heat instances
This function is called when a new resource is created but also when we
start the service up for the first time.
"""
for component in ("api", "api-cfn"):
utils.create_or_update('heat/deployment.yml.j2',
name=name, spec=spec, component=component)
utils.create_or_update('heat/service.yml.j2',
name=name, component=component)
utils.create_or_update('heat/deployment.yml.j2',
name=name, spec=spec, component='engine')

View File

@ -0,0 +1,80 @@
---
# Copyright 2020 VEXXHOST, Inc.
#
# 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.
{% if component is defined %}
{% set component = component %}
{% else %}
{% set component = "api" %}
{% endif %}
apiVersion: apps/v1
kind: Deployment
metadata:
name: heat-{{ name }}-{{ component }}
labels:
{{ labels("heat", name, component) | indent(4) }}
spec:
replicas: 3
selector:
matchLabels:
{{ labels("heat", name, component) | indent(6) }}
template:
metadata:
labels:
{{ labels("heat", name, component) | indent(8) }}
spec:
containers:
- name: heat-{{ component }}
image: vexxhost/heat-{{ component }}:latest
imagePullPolicy: Always
{% if 'api' in component %}
ports:
- name: heat-{{ component }}
containerPort: {% if component == 'api' %}8004{% else %}8000{% endif%}
livenessProbe:
tcpSocket:
port: heat-{{ component }}
readinessProbe:
tcpSocket:
port: heat-{{ component }}
{% endif %}
resources:
limits:
cpu: 1000m
ephemeral-storage: 50M
memory: 512M
requests:
cpu: 50m
ephemeral-storage: 50M
memory: 64M
securityContext:
runAsUser: 65534
runAsGroup: 65534
volumeMounts:
- mountPath: /etc/heat
name: config
volumes:
- name: config
hostPath:
path: {{ spec['configDir'] }}
type: Directory
{% if 'nodeSelector' in spec %}
nodeSelector:
{{ spec.nodeSelector | to_yaml | indent(8) }}
{% endif %}
{% if 'tolerations' in spec %}
tolerations:
{{ spec.tolerations | to_yaml | indent(8) }}
{% endif %}

View File

@ -0,0 +1,27 @@
---
# Copyright 2020 VEXXHOST, Inc.
#
# 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.
apiVersion: v1
kind: Service
metadata:
name: heat-{{ name }}-{{ component }}
spec:
serviceType: ClusterIP
ports:
- name: heat-{{ component }}
port: 80
targetPort: heat-{{ component }}
selector:
{{ labels("heat", name, component) | indent(4) }}

View File

@ -0,0 +1,27 @@
# Copyright 2020 VEXXHOST, Inc.
#
# 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.
"""Tests for Heat Operator
This module contains all the tests for the Heat operator.
"""
from openstack_operator.tests.unit import base
class HeatAPIDeploymentTestCase(base.DeploymentTestCase):
"""Basic tests for the Deployment."""
SAMPLE_FILE = 'orchestration_v1alpha1_heat.yaml'
TEMPLATE_FILE = 'heat/deployment.yml.j2'

View File

@ -4,6 +4,9 @@
provides: openstack-operator:image:ceilometer
vars: &id001
docker_images:
- context: images/ceilometer
repository: vexxhost/ceilometer
target: ceilometer
- context: images/ceilometer
repository: vexxhost/ceilometer-agent-notification
target: ceilometer-agent-notification

View File

@ -20,41 +20,45 @@
jobs:
- openstack-operator:functional:
dependencies:
- name: openstack-operator:images:build:ceilometer
soft: true
- name: openstack-operator:images:build:rabbitmq
soft: true
- name: openstack-operator:images:build:keystone
- name: openstack-operator:images:build:mcrouter-exporter
soft: true
- name: openstack-operator:images:build:horizon
soft: true
- name: openstack-operator:images:build:rabbitmq
soft: true
- name: openstack-operator:images:build:ceilometer
soft: true
- name: openstack-operator:images:build:memcached-exporter
soft: true
- name: openstack-operator:images:build:memcached
soft: true
- name: openstack-operator:images:build:keystone
soft: true
- name: openstack-operator:images:build:mcrouter
soft: true
- openstack-operator:images:build:openstack-operator
- name: openstack-operator:images:build:mcrouter-exporter
soft: true
- name: openstack-operator:images:build:memcached-exporter
- name: openstack-operator:images:build:heat
soft: true
gate:
jobs:
- openstack-operator:functional:
dependencies:
- name: openstack-operator:images:upload:ceilometer
soft: true
- name: openstack-operator:images:upload:rabbitmq
soft: true
- name: openstack-operator:images:upload:keystone
- name: openstack-operator:images:upload:mcrouter-exporter
soft: true
- name: openstack-operator:images:upload:horizon
soft: true
- name: openstack-operator:images:upload:rabbitmq
soft: true
- name: openstack-operator:images:upload:ceilometer
soft: true
- name: openstack-operator:images:upload:memcached-exporter
soft: true
- name: openstack-operator:images:upload:memcached
soft: true
- name: openstack-operator:images:upload:keystone
soft: true
- name: openstack-operator:images:upload:mcrouter
soft: true
- openstack-operator:images:upload:openstack-operator
- name: openstack-operator:images:upload:mcrouter-exporter
soft: true
- name: openstack-operator:images:upload:memcached-exporter
- name: openstack-operator:images:upload:heat
soft: true

45
zuul.d/heat-jobs.yaml Normal file
View File

@ -0,0 +1,45 @@
- job:
name: openstack-operator:images:build:heat
parent: vexxhost-build-docker-image
provides: openstack-operator:image:heat
vars: &id001
docker_images:
- context: images/heat
repository: vexxhost/heat-api-base
target: heat-api-base
- context: images/heat
repository: vexxhost/heat-api
target: heat-api
- context: images/heat
repository: vexxhost/heat-api-cfn
target: heat-api-cfn
- context: images/heat
repository: vexxhost/heat-engine
target: heat-engine
dependencies:
- openstack-operator:images:build:openstack-operator
files: &id002
- ^images/heat/.*
- job:
name: openstack-operator:images:upload:heat
parent: vexxhost-upload-docker-image
provides: openstack-operator:image:heat
vars: *id001
dependencies:
- openstack-operator:images:upload:openstack-operator
files: *id002
- job:
name: openstack-operator:images:promote:heat
parent: vexxhost-promote-docker-image
vars: *id001
files: *id002
- project:
check:
jobs:
- openstack-operator:images:build:heat
gate:
jobs:
- openstack-operator:images:upload:heat
promote:
jobs:
- openstack-operator:images:promote:heat