Allow additional Armada data to be provided
This commit is contained in:
parent
0726e89fe8
commit
d1334e4a59
@ -43,6 +43,9 @@ needed for a particular node.
|
|||||||
|
|
||||||
`spec` contains specific data for each kind of configuration document.
|
`spec` contains specific data for each kind of configuration document.
|
||||||
|
|
||||||
|
Additionally, documents for [Armada](https://github.com/att-comdev/armada) are
|
||||||
|
allowed and will be applied after CNI and DNS are deployed.
|
||||||
|
|
||||||
## Generating Configuration from Minimal Input
|
## Generating Configuration from Minimal Input
|
||||||
|
|
||||||
To construct a complete set of cluster configuration, the minimal input are
|
To construct a complete set of cluster configuration, the minimal input are
|
||||||
|
@ -60,7 +60,7 @@ metadata:
|
|||||||
target: all
|
target: all
|
||||||
spec:
|
spec:
|
||||||
images:
|
images:
|
||||||
armada: quay.io/attcomdev/armada:latest
|
armada: quay.io/attcomdev/armada:master
|
||||||
calico:
|
calico:
|
||||||
cni: quay.io/calico/cni:v1.9.1
|
cni: quay.io/calico/cni:v1.9.1
|
||||||
etcd: quay.io/coreos/etcd:v3.2.1
|
etcd: quay.io/coreos/etcd:v3.2.1
|
||||||
@ -85,3 +85,39 @@ spec:
|
|||||||
socat: socat=1.7.3.1-1
|
socat: socat=1.7.3.1-1
|
||||||
additional_packages:
|
additional_packages:
|
||||||
- ceph-common=10.2.7-0ubuntu0.16.04.1
|
- ceph-common=10.2.7-0ubuntu0.16.04.1
|
||||||
|
---
|
||||||
|
schema: armada/Manifest/v1
|
||||||
|
metadata:
|
||||||
|
schema: metadata/Document/v1
|
||||||
|
name: example-application
|
||||||
|
data:
|
||||||
|
release_prefix: example
|
||||||
|
chart_groups:
|
||||||
|
- example-application
|
||||||
|
---
|
||||||
|
schema: armada/ChartGroup/v1
|
||||||
|
metadata:
|
||||||
|
schema: metadata/Document/v1
|
||||||
|
name: example-application
|
||||||
|
data:
|
||||||
|
description: Just an example
|
||||||
|
chart_group:
|
||||||
|
- redis
|
||||||
|
---
|
||||||
|
schema: armada/Chart/v1
|
||||||
|
metadata:
|
||||||
|
schema: metadata/Document/v1
|
||||||
|
name: redis
|
||||||
|
data:
|
||||||
|
chart_name: redis
|
||||||
|
release: example-redis
|
||||||
|
namespace: default
|
||||||
|
timeout: 600
|
||||||
|
values:
|
||||||
|
persistence:
|
||||||
|
enabled: false
|
||||||
|
source:
|
||||||
|
type: git
|
||||||
|
location: https://github.com/kubernetes/charts.git
|
||||||
|
subpath: stable/redis
|
||||||
|
dependencies: []
|
||||||
|
@ -10,7 +10,22 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def load(f):
|
def load(f):
|
||||||
return Configuration(list(map(Document, yaml.load_all(f))))
|
return Configuration(list(map(instantiate_document, yaml.safe_load_all(f))))
|
||||||
|
|
||||||
|
|
||||||
|
def instantiate_document(data):
|
||||||
|
if data.get('schema', '').startswith('armada'):
|
||||||
|
return Document({
|
||||||
|
'apiVersion': 'promenade/v1',
|
||||||
|
'kind': 'ArmadaDocument',
|
||||||
|
'metadata': {
|
||||||
|
'name': data['schema'] + '/' + data['metadata']['name'],
|
||||||
|
'target': 'none',
|
||||||
|
},
|
||||||
|
'spec': data,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
return Document(data)
|
||||||
|
|
||||||
|
|
||||||
class Document:
|
class Document:
|
||||||
@ -22,6 +37,8 @@ class Document:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SUPPORTED_KINDS = {
|
SUPPORTED_KINDS = {
|
||||||
|
'ArmadaDocument',
|
||||||
|
|
||||||
'Certificate',
|
'Certificate',
|
||||||
'CertificateAuthority',
|
'CertificateAuthority',
|
||||||
'CertificateAuthorityKey',
|
'CertificateAuthorityKey',
|
||||||
@ -116,6 +133,9 @@ class Configuration:
|
|||||||
if not kind or document.kind == kind:
|
if not kind or document.kind == kind:
|
||||||
yield document
|
yield document
|
||||||
|
|
||||||
|
def get_armada_documents(self):
|
||||||
|
return [d.data['spec'] for d in self.iterate(kind='ArmadaDocument')]
|
||||||
|
|
||||||
def _iterate_with_target(self, target):
|
def _iterate_with_target(self, target):
|
||||||
for document in self.documents:
|
for document in self.documents:
|
||||||
if document.target == target or document.target == 'all':
|
if document.target == target or document.target == 'all':
|
||||||
|
@ -41,6 +41,7 @@ class Generator:
|
|||||||
cluster = self.input_config['Cluster']
|
cluster = self.input_config['Cluster']
|
||||||
network = self.input_config['Network']
|
network = self.input_config['Network']
|
||||||
versions = self.input_config['Versions']
|
versions = self.input_config['Versions']
|
||||||
|
armada_documents = list(self.input_config.iterate(kind='ArmadaDocument'))
|
||||||
|
|
||||||
cluster_name = cluster.metadata['name']
|
cluster_name = cluster.metadata['name']
|
||||||
LOG.info('Generating configuration for cluster "%s"', cluster_name)
|
LOG.info('Generating configuration for cluster "%s"', cluster_name)
|
||||||
@ -198,6 +199,7 @@ class Generator:
|
|||||||
role_specific_documents.extend(master_documents)
|
role_specific_documents.extend(master_documents)
|
||||||
|
|
||||||
if 'genesis' in data.get('roles', []):
|
if 'genesis' in data.get('roles', []):
|
||||||
|
role_specific_documents.extend(armada_documents)
|
||||||
role_specific_documents.extend(_genesis_config(hostname, data,
|
role_specific_documents.extend(_genesis_config(hostname, data,
|
||||||
masters, network, keys))
|
masters, network, keys))
|
||||||
role_specific_documents.append(_genesis_etcd_config(cluster_name, hostname))
|
role_specific_documents.append(_genesis_etcd_config(cluster_name, hostname))
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
from . import logging
|
from . import logging
|
||||||
import base64
|
import base64
|
||||||
|
import io
|
||||||
import jinja2
|
import jinja2
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
import yaml
|
||||||
|
|
||||||
__all__ = ['Renderer']
|
__all__ = ['Renderer']
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ class Renderer:
|
|||||||
loader=jinja2.PackageLoader('promenade', 'templates/include'),
|
loader=jinja2.PackageLoader('promenade', 'templates/include'),
|
||||||
undefined=jinja2.StrictUndefined)
|
undefined=jinja2.StrictUndefined)
|
||||||
env.filters['b64enc'] = _base64_encode
|
env.filters['b64enc'] = _base64_encode
|
||||||
|
env.filters['yaml_safe_dump_all'] = _yaml_safe_dump_all
|
||||||
|
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
template = env.from_string(f.read())
|
template = env.from_string(f.read())
|
||||||
@ -63,3 +66,9 @@ def _ensure_path(path):
|
|||||||
|
|
||||||
def _base64_encode(s):
|
def _base64_encode(s):
|
||||||
return base64.b64encode(s.encode()).decode()
|
return base64.b64encode(s.encode()).decode()
|
||||||
|
|
||||||
|
|
||||||
|
def _yaml_safe_dump_all(documents):
|
||||||
|
f = io.StringIO()
|
||||||
|
yaml.safe_dump_all(documents, f)
|
||||||
|
return f.getvalue()
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{{ config.get_armada_documents() | yaml_safe_dump_all }}
|
@ -19,11 +19,11 @@ spec:
|
|||||||
- |-
|
- |-
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
mkdir -p /root/.kube
|
||||||
|
cp /etc/kubernetes/armada-loader/kubeconfig.yaml /root/.kube/config
|
||||||
|
|
||||||
cd /etc/kubernetes/armada-loader/assets
|
cd /etc/kubernetes/armada-loader/assets
|
||||||
if [ -s promenade-armada.yaml ]; then
|
if [ -s promenade-armada.yaml ]; then
|
||||||
mkdir -p /root/.kube
|
|
||||||
cp /etc/kubernetes/armada-loader/kubeconfig.yaml /root/.kube/config
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
sleep 10
|
sleep 10
|
||||||
if armada --debug apply --tiller-host 127.0.0.1 promenade-armada.yaml ; then
|
if armada --debug apply --tiller-host 127.0.0.1 promenade-armada.yaml ; then
|
||||||
@ -32,6 +32,15 @@ spec:
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -s external-armada.yaml ]; then
|
||||||
|
while true; do
|
||||||
|
sleep 10
|
||||||
|
if armada --debug apply --tiller-host 127.0.0.1 external-armada.yaml ; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf /etc/kubernetes/kubelet/manifests/armada-loader.yaml
|
rm -rf /etc/kubernetes/kubelet/manifests/armada-loader.yaml
|
||||||
# Sleep so that kubelet doesn't restart this pod before it kills it
|
# Sleep so that kubelet doesn't restart this pod before it kills it
|
||||||
sleep 10000
|
sleep 10000
|
||||||
|
Loading…
Reference in New Issue
Block a user