Create HELM chart for nova-api-proxy

New helm chart created for nova-api-proxy
New module added to helm overrides to configure nova-api-proxy.conf
Turned of yamllint for helm charts, openstack helm charts are yaml
files but not proper yaml syntax

Story: 2004007
Task: 26953

Change-Id: Ic45d6cb801e142ddd7fc7da1638ba0e65cbacc22
Signed-off-by: Lachlan Plant <lachlan.plant@windriver.com>
This commit is contained in:
Lachlan Plant 2018-10-25 12:15:01 -05:00
parent e715aa2369
commit 3a15f73bfb
19 changed files with 689 additions and 3 deletions

View File

@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: StarlingX-Helm nova-api-proxy
name: nova-api-proxy
version: 0.1.0

View File

@ -0,0 +1,10 @@
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
dependencies:
- name: helm-toolkit
repository: http://localhost:8879/charts
version: 0.1.0

View File

@ -0,0 +1,13 @@
#!/bin/bash
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
set -ex
nova-api-proxy --config-file=/etc/proxy/nova-api-proxy.conf

View File

@ -0,0 +1,19 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if .Values.manifests.configmap_bin }}
{{- $envAll := . }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nova-api-proxy-bin
data:
nova-api-proxy.sh: |
{{ tuple "bin/_nova-api-proxy.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- end }}

View File

@ -0,0 +1,55 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- define "nova_proxy.configmap.etc" }}
{{- $envAll := index . 1 }}
{{- with $envAll }}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.auth_uri -}}
{{- $_ := tuple "identity" "internal" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | set .Values.conf.nova_api_proxy.keystone_authtoken "auth_uri" -}}
{{- end -}}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.auth_url -}}
{{- $_ := tuple "identity" "internal" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | set .Values.conf.nova_api_proxy.keystone_authtoken "auth_url" -}}
{{- end -}}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.region_name -}}
{{- $_ := set .Values.conf.nova_api_proxy.keystone_authtoken "region_name" .Values.endpoints.identity.auth.nova.region_name -}}
{{- end -}}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.project_name -}}
{{- $_ := set .Values.conf.nova_api_proxy.keystone_authtoken "project_name" .Values.endpoints.identity.auth.nova.project_name -}}
{{- end -}}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.project_domain_name -}}
{{- $_ := set .Values.conf.nova_api_proxy.keystone_authtoken "project_domain_name" .Values.endpoints.identity.auth.nova.project_domain_name -}}
{{- end -}}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.user_domain_name -}}
{{- $_ := set .Values.conf.nova_api_proxy.keystone_authtoken "user_domain_name" .Values.endpoints.identity.auth.nova.user_domain_name -}}
{{- end -}}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.username -}}
{{- $_ := set .Values.conf.nova_api_proxy.keystone_authtoken "username" .Values.endpoints.identity.auth.nova.username -}}
{{- end -}}
{{- if empty .Values.conf.nova_api_proxy.keystone_authtoken.password -}}
{{- $_ := set .Values.conf.nova_api_proxy.keystone_authtoken "password" .Values.endpoints.identity.auth.nova.password -}}
{{- end -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: nova-api-proxy-etc
data:
nova-api-proxy.conf: |
{{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.nova_api_proxy | indent 4 }}
api-proxy-paste.ini: |
{{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.paste | indent 4 }}
logging.conf: |
{{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.logging | indent 4 }}
{{- end }}
{{- end }}
{{- if .Values.manifests.configmap_etc }}
{{- list "nova-proxy-etc" . | include "nova_proxy.configmap.etc" }}
{{- end }}

View File

@ -0,0 +1,88 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if .Values.manifests.deployment_api_proxy }}
{{- $envAll := . }}
{{- $mounts_nova_api_proxy := .Values.pod.mounts.nova_api_proxy.nova_api_proxy }}
{{- $mounts_nova_api_proxy_init := .Values.pod.mounts.nova_api_proxy.init_container }}
{{- $serviceAccountName := "nova-api-proxy" }}
{{ tuple $envAll "proxy" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nova-api-proxy
labels:
{{ tuple $envAll "nova" "api-proxy" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
spec:
replicas: {{ .Values.pod.replicas.proxy }}
selector:
matchLabels:
{{ tuple $envAll "nova" "api-proxy" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
{{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }}
template:
metadata:
labels:
{{ tuple $envAll "nova" "api-proxy" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
annotations:
configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }}
configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }}
spec:
serviceAccountName: {{ $serviceAccountName }}
affinity:
{{ tuple $envAll "nova" "api-proxy" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector:
{{ .Values.labels.api_proxy.node_selector_key }}: {{ .Values.labels.api_proxy.node_selector_value }}
terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.api_proxy.timeout | default "30" }}
initContainers:
{{ tuple $envAll "api" $mounts_nova_api_proxy_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: nova-api-proxy
{{ tuple $envAll "nova_api_proxy" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.api_proxy | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
securityContext:
runAsUser: {{ .Values.pod.user.nova_api_proxy.uid }}
command:
- /tmp/nova-api-proxy.sh
ports:
- name: n-api
containerPort: {{ tuple "compute" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
readinessProbe:
tcpSocket:
port: {{ tuple "compute" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
volumeMounts:
- name: nova-api-proxy-bin
mountPath: /tmp/nova-api-proxy.sh
subPath: nova-api-proxy.sh
readOnly: true
- name: nova-api-proxy-etc
mountPath: /etc/proxy/nova-api-proxy.conf
subPath: nova-api-proxy.conf
readOnly: true
- name: nova-api-proxy-etc
mountPath: /etc/proxy/logging.conf
subPath: logging.conf
readOnly: true
- name: nova-api-proxy-etc
mountPath: /etc/proxy/api-proxy-paste.ini
subPath: api-proxy-paste.ini
readOnly: true
{{ if $mounts_nova_api_proxy.volumeMounts }}{{ toYaml $mounts_nova_api_proxy.volumeMounts | indent 12 }}{{ end }}
volumes:
- name: nova-api-proxy-bin
configMap:
name: nova-api-proxy-bin
defaultMode: 0777
- name: nova-api-proxy-etc
configMap:
name: nova-api-proxy-etc
defaultMode: 0777
{{ if $mounts_nova_api_proxy.volumes}}{{ toYaml $mounts_nova_api_proxy.volumes | indent 8 }}{{ end }}
{{- end }}

View File

@ -0,0 +1,13 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if and .Values.manifests.job_image_repo_sync .Values.images.local_registry.active }}
{{- $imageRepoSyncJob := dict "envAll" . "serviceName" "nova-api-proxy" -}}
{{ $imageRepoSyncJob | include "helm-toolkit.manifests.job_image_repo_sync" }}
{{- end }}

View File

@ -0,0 +1,12 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if and .Values.manifests.ingress .Values.network.api_proxy.ingress.public }}
{{- $ingressOpts := dict "envAll" . "backendServiceType" "compute" "backendPort" "n-api-proxy" -}}
{{ $ingressOpts | include "helm-toolkit.manifests.ingress" }}
{{- end }}

View File

@ -0,0 +1,12 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if .Values.manifests.job_ks_endpoints }}
{{- $ksServiceJob := dict "envAll" . "serviceName" "nova" "serviceTypes" ( tuple "compute" ) -}}
{{ $ksServiceJob | include "helm-toolkit.manifests.job_ks_endpoints" }}
{{- end }}

View File

@ -0,0 +1,11 @@
{{/*
#
#Copyright (c) 2018 Wind River Systems, Inc.
#
#SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if .Values.manifests.secret_ingress_tls }}
{{ include "helm-toolkit.manifests.secret_ingress_tls" ( dict "envAll" . "backendService" "osapi" "backendServiceType" "compute" ) }}
{{- end }}

View File

@ -0,0 +1,22 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if .Values.manifests.secret_keystone }}
{{- $envAll := . }}
{{- range $key1, $userClass := tuple "admin" "nova" "test" }}
{{- $secretName := index $envAll.Values.secrets.identity $userClass }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ $secretName }}
type: Opaque
data:
{{- tuple $userClass "internal" $envAll | include "helm-toolkit.snippets.keystone_secret_openrc" | indent 2 -}}
{{- end }}
{{- end }}

View File

@ -0,0 +1,31 @@
{{/*
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
*/}}
{{- if .Values.manifests.service_api }}
{{- $envAll := . }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ tuple "nova" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
spec:
ports:
- name: n-api-proxy
port: {{ tuple "compute" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
{{ if .Values.network.api.node_port.enabled }}
nodePort: {{ .Values.network.api.node_port.port }}
{{ end }}
selector:
{{ tuple $envAll "nova" "api" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
{{ if .Values.network.api.node_port.enabled }}
type: NodePort
{{ if .Values.network.api.external_policy_local }}
externalTrafficPolicy: Local
{{ end }}
{{ end }}
{{- end }}

View File

@ -0,0 +1,306 @@
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Default values for nova-api-proxy.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
labels:
api_proxy:
node_selector_key: openstack-control-plane
node_selector_value: enabled
job:
node_selector_key: openstack-control-plane
node_selector_value: enabled
images:
tags:
nova_api_proxy: 128.224.186.231:9001/abailey/stx-nova-api-proxy:latest
ks_endpoints: docker.io/openstackhelm/heat:pike
dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
pullPolicy: IfNotPresent
local_registry:
active: false
exclude:
- dep_check
- image_repo_sync
network:
api_proxy:
ingress:
public: true
classes:
namespace: "nginx"
cluster: "nginx-cluster"
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
external_policy_local: false
node_port:
enabled: false
port: 8774
conf:
nova_api_proxy:
DEFAULT:
log_config_append: /etc/proxy/logging.conf
api_paste_config: api-proxy-paste.ini
auth_strategy: keystone
debug: False
use_syslog: False
show_request_body: False
pool_size: 256
osapi_proxy_listen: 0.0.0.0
osapi_proxy_listen_port: 8774
osapi_compute_listen: nova-api.openstack.svc.cluster.local
osapi_compute_listen_port: 8774
nfvi_compute_listen_port: 30003
nfvi_compute_listen: 0.0.0.0
keystone_authtoken:
auth_type: password
auth_version: v3
paste:
pipeline:nova-api-proxy:
pipeline: version authtoken acceptor proxyapp
filter:debug_header:
paste.filter_factory: nova_api_proxy.apps.acceptor:DebugHeaders.factory
filter:version:
paste.filter_factory: nova_api_proxy.apps.acceptor:VersionAcceptor.factory
filter:authtoken:
paste.filter_factory: keystonemiddleware.auth_token:filter_factory
filter:acceptor:
paste.filter_factory: nova_api_proxy.apps.acceptor:Acceptor.factory
app:proxyapp:
paste.app_factory: nova_api_proxy.apps.proxy:Proxy.factory
logging:
loggers:
keys:
- root
- nova_api_proxy
- keystonemiddleware
handlers:
keys:
- stdout
- stderr
- "null"
formatters:
keys:
- context
- default
logger_root:
level: WARNING
handlers: null
logger_nova_api_proxy:
level: INFO
handlers:
- stdout
qualname: nova_api_proxy
logger_keystonemiddleware:
level: INFO
handlers:
- stdout
qualname: keystonemiddleware
logger_amqp:
level: WARNING
handlers: stderr
qualname: amqp
logger_amqplib:
level: WARNING
handlers: stderr
qualname: amqplib
logger_eventletwsgi:
level: WARNING
handlers: stderr
qualname: eventlet.wsgi.server
logger_sqlalchemy:
level: WARNING
handlers: stderr
qualname: sqlalchemy
logger_boto:
level: WARNING
handlers: stderr
qualname: boto
handler_null:
class: logging.NullHandler
formatter: default
args: ()
handler_stdout:
class: StreamHandler
args: (sys.stdout,)
formatter: context
handler_stderr:
class: StreamHandler
args: (sys.stderr,)
formatter: context
formatter_context:
class: oslo_log.formatters.ContextFormatter
formatter_default:
format: "%(message)s"
dependencies:
dynamic:
common:
local_image_registry:
jobs:
- image-repo-sync
services:
- endpoint: node
service: local_image_registry
static:
ks_endpoints:
jobs:
- nova-ks-service
services:
- endpoint: internal
service: identity
endpoints:
cluster_domain_suffix: cluster.local
local_image_registry:
name: docker-registry
namespace: docker-registry
hosts:
default: localhost
internal: docker-registry
node: localhost
host_fqdn_override:
default: null
port:
registry:
node: 5000
identity:
name: keystone
auth:
admin:
region_name: RegionOne
username: admin
password: password
project_name: admin
user_domain_name: default
project_domain_name: default
nova:
role: admin
region_name: RegionOne
username: nova
password: password
project_name: service
user_domain_name: service
project_domain_name: service
hosts:
default: keystone-api
public: keystone
host_fqdn_override:
default: null
path:
default: /v3
scheme:
default: http
port:
admin:
default: 35357
api:
default: 80
compute:
name: nova
hosts:
default: nova-api-proxy
public: nova-api-proxy
host_fqdn_override:
default: null
# NOTE(portdirect): this chart supports TLS for fqdn over-ridden public
# endpoints using the following format:
# public:
# host: null
# tls:
# crt: null
# key: null
path:
default: "/v2.1/%(tenant_id)s"
scheme:
default: 'http'
port:
api:
default: 8774
public: 80
pod:
user:
nova_api_proxy:
uid: 42424
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts:
nova_api_proxy:
init_container: null
nova_api_proxy:
replicas:
proxy: 1
lifecycle:
upgrades:
deployments:
revision_history: 3
pod_replacement_strategy: RollingUpdate
rolling_update:
max_unavailable: 1
max_surge: 3
daemonsets:
pod_replacement_strategy: RollingUpdate
compute:
enabled: true
min_ready_seconds: 0
max_unavailable: 1
disruption_budget:
api_proxy:
min_available: 0
termination_grace_period:
api_proxy:
timeout: 30
resources:
enabled: false
api_proxy:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "1024Mi"
cpu: "2000m"
jobs:
ks_endpoints:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "1024Mi"
cpu: "2000m"
secrets:
identity:
admin: nova-keystone-admin
nova: nova-keystone-user
manifests:
configmap_bin: true
configmap_etc: true
deployment_api_proxy: true
ingress_api: true
job_ks_endpoints: false
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}

View File

@ -1368,11 +1368,11 @@ HELM_CHART_MEMCACHED = 'memcached'
HELM_CHART_NEUTRON = 'neutron'
HELM_CHART_NFS_PROVISIONER = 'nfs-provisioner'
HELM_CHART_NOVA = 'nova'
HELM_CHART_NOVA_API_PROXY = 'nova-api-proxy'
HELM_CHART_OPENVSWITCH = 'openvswitch'
HELM_CHART_RABBITMQ = 'rabbitmq'
HELM_CHART_RBD_PROVISIONER = 'rbd-provisioner'
SUPPORTED_HELM_CHARTS = [
HELM_CHART_BARBICAN,
HELM_CHART_CEILOMETER,
@ -1391,6 +1391,7 @@ SUPPORTED_HELM_CHARTS = [
HELM_CHART_NEUTRON,
HELM_CHART_NFS_PROVISIONER,
HELM_CHART_NOVA,
HELM_CHART_NOVA_API_PROXY,
HELM_CHART_OPENVSWITCH,
HELM_CHART_RABBITMQ,
HELM_CHART_RBD_PROVISIONER,
@ -1426,6 +1427,7 @@ SUPPORTED_HELM_APP_CHARTS = {
HELM_CHART_LIBVIRT,
HELM_CHART_NEUTRON,
HELM_CHART_NOVA,
HELM_CHART_NOVA_API_PROXY,
HELM_CHART_CINDER,
HELM_CHART_GNOCCHI,
HELM_CHART_CEILOMETER,

View File

@ -12,6 +12,7 @@ from sysinv.common import constants
from sysinv.common import exception
from sysinv.common import utils
from sysinv.common.storage_backend_conf import StorageBackendConfig
from sysinv.openstack.common import log as logging
from . import common
@ -176,3 +177,8 @@ class BaseHelm(object):
utils._format_ceph_mon_address(mon, port) for mon in monitor_ips
]
return formatted_monitor_ips
def _get_management_address(self):
address = self._get_address_by_name(
constants.CONTROLLER_HOSTNAME, constants.NETWORK_TYPE_MGMT)
return address.address

View File

@ -45,7 +45,7 @@ from . import rabbitmq
# Chart source: Custom
from . import rbd_provisioner
from . import nova_api_proxy
LOG = logging.getLogger(__name__)
@ -104,6 +104,8 @@ class HelmOperator(object):
constants.HELM_CHART_NFS_PROVISIONER:
nfs_provisioner.NfsProvisionerHelm(self),
constants.HELM_CHART_NOVA: nova.NovaHelm(self),
constants.HELM_CHART_NOVA_API_PROXY:
nova_api_proxy.NovaApiProxyHelm(self),
constants.HELM_CHART_OPENVSWITCH:
openvswitch.OpenvswitchHelm(self),
constants.HELM_CHART_RABBITMQ: rabbitmq.RabbitmqHelm(self),

View File

@ -0,0 +1,79 @@
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from sysinv.common import constants
from sysinv.common import exception
from sysinv.openstack.common import log as logging
from . import common
from . import openstack
LOG = logging.getLogger(__name__)
class NovaApiProxyHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the nova chart"""
CHART = constants.HELM_CHART_NOVA_API_PROXY
SUPPORTED_NAMESPACES = [
common.HELM_NS_OPENSTACK
]
SERVICE_NAME = 'nova'
AUTH_USERS = ['nova']
def get_namespaces(self):
return self.SUPPORTED_NAMESPACES
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': {
'user': {
'nova_api_proxy': {
'uid': 0
}
}
},
'conf': {
'nova_api_proxy': {
'DEFAULT': {
'nfvi_compute_listen': self._get_management_address()
},
}
},
'endpoints': self._get_endpoints_overrides(),
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_endpoints_identity_users_overrides(self):
overrides = {}
overrides.update(self._get_common_users_overrides(self.SERVICE_NAME))
for user in self.AUTH_USERS:
overrides.update({
user: {
'region_name': self._region_name(),
'password': self._get_keyring_password(self.SERVICE_NAME, user)
}
})
return overrides
def _get_endpoints_identity_overrides(self):
return {'auth': self._get_endpoints_identity_users_overrides()}
def _get_endpoints_overrides(self):
return {
'identity': self._get_endpoints_identity_overrides(),
}

View File

@ -26,7 +26,7 @@ commands =
-i E006,E010"
bash -c "find {toxinidir} \
\( -name .tox -prune \) \
\( -name .tox -o -path {toxinidir}/kubernetes/helm-charts -prune \) \
-o -type f -name '*.yaml' \
-print0 | xargs -0 yamllint -f parsable \
-c {toxinidir}/.yamllint"