adding support for postgres volume mount
This commit is contained in:
parent
a5a8831c1c
commit
4eecdbaf87
8
Makefile
8
Makefile
@ -1,12 +1,12 @@
|
||||
.PHONY: ceph bootstrap mariadb keystone memcached rabbitmq common openstack neutron all clean
|
||||
.PHONY: ceph bootstrap mariadb keystone memcached rabbitmq common openstack neutron maas all clean
|
||||
|
||||
B64_DIRS := common/secrets
|
||||
B64_EXCLUDE := $(wildcard common/secrets/*.b64)
|
||||
|
||||
CHARTS := ceph mariadb rabbitmq GLANCE memcached keystone glance horizon neutron openstack
|
||||
CHARTS := ceph mariadb rabbitmq GLANCE memcached keystone glance horizon neutron maas openstack
|
||||
COMMON_TPL := common/templates/_globals.tpl
|
||||
|
||||
all: common ceph bootstrap mariadb rabbitmq memcached keystone glance horizon neutron openstack
|
||||
all: common ceph bootstrap mariadb rabbitmq memcached keystone glance horizon neutron maas openstack
|
||||
|
||||
common: build-common
|
||||
|
||||
@ -27,6 +27,8 @@ glance: build-glance
|
||||
|
||||
neutron: build-neutron
|
||||
|
||||
maas: build-maas
|
||||
|
||||
memcached: build-memcached
|
||||
|
||||
openstack: build-openstack
|
||||
|
4
maas/requirements.yaml
Normal file
4
maas/requirements.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: http://localhost:8879/charts
|
||||
version: 0.1.0
|
3
maas/templates/_helpers.tpl
Normal file
3
maas/templates/_helpers.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
{{- define "joinListWithColon" -}}
|
||||
{{ range $k, $v := . }}{{ if $k }},{{ end }}{{ $v }}{{ end }}
|
||||
{{- end -}}
|
14
maas/templates/bin/_start.sh.tpl
Normal file
14
maas/templates/bin/_start.sh.tpl
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
if ! find "/etc/postgresql" -mindepth 1 -print -quit | grep -q .; then
|
||||
pg_createcluster 9.5 main
|
||||
fi
|
||||
|
||||
cp -r /etc/postgresql/9.5/main/*.conf /var/lib/postgresql/9.5/main/
|
||||
pg_ctlcluster 9.5 main start
|
||||
|
||||
echo 'running postinst'
|
||||
|
||||
chmod 755 /var/lib/dpkg/info/maas-region-controller.postinst
|
||||
/bin/sh /var/lib/dpkg/info/maas-region-controller.postinst configure
|
7
maas/templates/configmap-bin.yaml
Normal file
7
maas/templates/configmap-bin.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: maas-region-bin
|
||||
data:
|
||||
start.sh: |
|
||||
{{ tuple "bin/_start.sh.tpl" . | include "template" | indent 4 }}
|
7
maas/templates/configmap-etc.yaml
Normal file
7
maas/templates/configmap-etc.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: maas-region-etc
|
||||
data:
|
||||
named.conf.options: |+
|
||||
{{ tuple "etc/_region-dns-config.tpl" . | include "template" | indent 4 }}
|
10
maas/templates/configmap-var.yaml
Normal file
10
maas/templates/configmap-var.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: maas-region-var
|
||||
data:
|
||||
maas-region-controller.postinst: |
|
||||
{{ tuple "var/_maas-region-controller.postinst.tpl" . | include "template" | indent 4 }}
|
||||
secret: |
|
||||
{{ tuple "var/_secret.tpl" . | include "template" | indent 4 }}
|
||||
|
@ -1,12 +1,55 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1beta1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: maas-region
|
||||
spec:
|
||||
serviceName: "{{ .Values.service_name }}"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: maas-region
|
||||
annotations:
|
||||
pod.beta.kubernetes.io/init-containers: '[
|
||||
{
|
||||
"name": "init",
|
||||
"image": "{{ .Values.images.maas_region }}",
|
||||
"imagePullPolicy": "Always",
|
||||
"command": [
|
||||
"/bin/bash", "-c"
|
||||
],
|
||||
"args": [
|
||||
"chmod +x /tmp/start.sh; /tmp/start.sh"
|
||||
],
|
||||
"volumeMounts": [
|
||||
{
|
||||
"name": "maas-config",
|
||||
"mountPath": "/etc/maas/"
|
||||
},
|
||||
{
|
||||
"name": "postgresql-config",
|
||||
"mountPath": "/etc/postgresql"
|
||||
},
|
||||
{
|
||||
"name": "postgresql-data",
|
||||
"mountPath": "/var/lib/postgresql"
|
||||
},
|
||||
{
|
||||
"name": "postgresql-run",
|
||||
"mountPath": "/var/run/postgresql"
|
||||
},
|
||||
{
|
||||
"name": "startsh",
|
||||
"mountPath": "/tmp/start.sh",
|
||||
"subPath": "start.sh"
|
||||
},
|
||||
{
|
||||
"name": "maasregionpostinst",
|
||||
"mountPath": "/var/lib/dpkg/info/maas-region-controller.postinst",
|
||||
"subPath": "maas-region-controller.postinst"
|
||||
}
|
||||
]
|
||||
}
|
||||
]'
|
||||
spec:
|
||||
nodeSelector:
|
||||
{{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
|
||||
@ -18,3 +61,45 @@ spec:
|
||||
- containerPort: {{ .Values.network.port.region_container }}
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: postgresql-data
|
||||
mountPath: /var/lib/postgresql
|
||||
- name: postgresql-run
|
||||
mountPath: /var/run/postgresql
|
||||
- name: maas-lib
|
||||
mountPath: /var/lib/maas
|
||||
- name: maas-region-secret
|
||||
mountPath: /var/lib/maas/secret
|
||||
subPath: secret
|
||||
- name: postgresql-config
|
||||
mountPath: /etc/postgresql
|
||||
- name: maas-dns-config
|
||||
mountPath: /etc/bind/named.conf.options
|
||||
subPath: named.conf.options
|
||||
- name: maas-config
|
||||
mountPath: /etc/maas/regiond.conf
|
||||
subPath: regiond.conf
|
||||
volumes:
|
||||
- name: postgresql-data
|
||||
hostPath:
|
||||
path: /var/lib/postgresql
|
||||
- name: postgresql-run
|
||||
emptyDir: {}
|
||||
- name: postgresql-config
|
||||
emptyDir: {}
|
||||
- name: maas-lib
|
||||
emptyDir: {}
|
||||
- name: maas-region-secret
|
||||
configMap:
|
||||
name: maas-region-var
|
||||
- name: maas-config
|
||||
emptyDir: {}
|
||||
- name: maas-dns-config
|
||||
configMap:
|
||||
name: maas-region-etc
|
||||
- name: startsh
|
||||
configMap:
|
||||
name: maas-region-bin
|
||||
- name: maasregionpostinst
|
||||
configMap:
|
||||
name: maas-region-var
|
||||
|
4
maas/templates/etc/_region-dns-config.tpl
Normal file
4
maas/templates/etc/_region-dns-config.tpl
Normal file
@ -0,0 +1,4 @@
|
||||
options { directory "/var/cache/bind";
|
||||
auth-nxdomain no;
|
||||
listen-on-v6 { any; };
|
||||
include "/etc/bind/maas/named.conf.options.inside.maas"; };
|
@ -1,10 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: maas-region-ui
|
||||
name: {{ .Values.service_name }}
|
||||
labels:
|
||||
app: maas-region-ui
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: {{ .Values.network.port.service_gui }}
|
||||
targetPort: {{ .Values.network.port.service_gui_target }}
|
||||
|
149
maas/templates/var/_maas-region-controller.postinst.tpl
Normal file
149
maas/templates/var/_maas-region-controller.postinst.tpl
Normal file
@ -0,0 +1,149 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
db_version 2.0
|
||||
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
|
||||
. /usr/share/dbconfig-common/dpkg/postinst.pgsql
|
||||
fi
|
||||
|
||||
RELEASE=`lsb_release -rs` || RELEASE=""
|
||||
|
||||
maas_sync_migrate_db(){
|
||||
maas-region dbupgrade
|
||||
}
|
||||
|
||||
restart_postgresql(){
|
||||
invoke-rc.d --force postgresql restart || true
|
||||
}
|
||||
|
||||
configure_maas_default_url() {
|
||||
local ipaddr="$1"
|
||||
# The given address is either "[IPv6_IP]" or "IPv4_IP" or "name", such as
|
||||
# [2001:db8::3:1]:5555 or 127.0.0.1 or maas.example.com.
|
||||
# The ugly sed splits the given thing as:
|
||||
# (string of anything but ":", or [ipv6_ip]),
|
||||
# optionally followed by :port.
|
||||
local address=$(echo "$ipaddr" |
|
||||
sed -rn 's/^([^:]*|\[[0-9a-fA-F:]*\])(|:[0-9]*)?$/\1/p')
|
||||
local port=$(echo "$ipaddr" |
|
||||
sed -rn 's/^([^:]*|\[[0-9a-fA-F:]*\])(|:[0-9]*)?$/\2/p')
|
||||
test -n "$port" || port=":80"
|
||||
ipaddr="${ipaddr}${port}"
|
||||
maas-region local_config_set --maas-url "http://${ipaddr}/MAAS"
|
||||
}
|
||||
|
||||
get_default_route_ip6() {
|
||||
while read Src SrcPref Dest DestPref Gateway Metric RefCnt Use Flags Iface
|
||||
do
|
||||
[ "$SrcPref" = 00 ] && [ "$Iface" != lo ] && break
|
||||
done < /proc/net/ipv6_route
|
||||
if [ -n "$Iface" ]; then
|
||||
LC_ALL=C /sbin/ip -6 addr list dev "$Iface" scope global permanent |
|
||||
sed -n '/ inet6 /s/.*inet6 \([0-9a-fA-F:]*\).*/[\1]/p' | head -1
|
||||
fi
|
||||
}
|
||||
|
||||
get_default_route_ip4() {
|
||||
while read Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
|
||||
do
|
||||
[ "$Mask" = "00000000" ] && break
|
||||
done < /proc/net/route
|
||||
if [ -n "$Iface" ]; then
|
||||
ipaddr=$(LC_ALL=C /sbin/ip -4 addr list dev "$Iface" scope global)
|
||||
ipaddr=${ipaddr#* inet }
|
||||
ipaddr=${ipaddr%%/*}
|
||||
echo $ipaddr
|
||||
fi
|
||||
}
|
||||
|
||||
extract_default_maas_url() {
|
||||
# Extract DEFAULT_MAAS_URL IP/host setting from config file $1.
|
||||
grep "^DEFAULT_MAAS_URL" "$1" | cut -d"/" -f3
|
||||
}
|
||||
|
||||
configure_migrate_maas_dns() {
|
||||
# This only runs on upgrade. We only run this if the
|
||||
# there are forwarders to migrate or no
|
||||
# named.conf.options.inside.maas are present.
|
||||
maas-region edit_named_options \
|
||||
--migrate-conflicting-options --config-path \
|
||||
/etc/bind/named.conf.options
|
||||
invoke-rc.d bind9 restart || true
|
||||
}
|
||||
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
#########################################################
|
||||
########## Configure DEFAULT_MAAS_URL #################
|
||||
#########################################################
|
||||
|
||||
# Obtain IP address of default route and change DEFAULT_MAAS_URL
|
||||
# if default-maas-url has not been preseeded. Prefer ipv4 addresses if
|
||||
# present, and use "localhost" only if there is no default route in either
|
||||
# address family.
|
||||
db_get maas/default-maas-url
|
||||
ipaddr="$RET"
|
||||
if [ -z "$ipaddr" ]; then
|
||||
#ipaddr=$(get_default_route_ip4)
|
||||
ipaddr="maas-region-ui.{{ .Release.Namespace }}"
|
||||
fi
|
||||
if [ -z "$ipaddr" ]; then
|
||||
#ipaddr=$(get_default_route_ip6)
|
||||
ipaddr="maas-region-ui.{{ .Release.Namespace }}"
|
||||
fi
|
||||
# Fallback default is "localhost"
|
||||
if [ -z "$ipaddr" ]; then
|
||||
ipaddr=localhost
|
||||
fi
|
||||
# Set the IP address of the interface with default route
|
||||
configure_maas_default_url "$ipaddr"
|
||||
db_subst maas/installation-note MAAS_URL "$ipaddr"
|
||||
db_set maas/default-maas-url "$ipaddr"
|
||||
|
||||
#########################################################
|
||||
################ Configure Database ###################
|
||||
#########################################################
|
||||
|
||||
# Need to for postgresql start so it doesn't fail on the installer
|
||||
restart_postgresql
|
||||
|
||||
# Create the database
|
||||
dbc_go maas-region-controller $@
|
||||
maas-region local_config_set \
|
||||
--database-host "localhost" --database-name "$dbc_dbname" \
|
||||
--database-user "$dbc_dbuser" --database-pass "$dbc_dbpass"
|
||||
|
||||
# Only syncdb if we have selected to install it with dbconfig-common.
|
||||
db_get maas-region-controller/dbconfig-install
|
||||
if [ "$RET" = "true" ]; then
|
||||
maas_sync_migrate_db
|
||||
configure_migrate_maas_dns
|
||||
fi
|
||||
|
||||
db_get maas/username
|
||||
username="$RET"
|
||||
if [ -n "$username" ]; then
|
||||
db_get maas/password
|
||||
password="$RET"
|
||||
if [ -n "$password" ]; then
|
||||
maas-region createadmin --username "$username" --password "$password" --email "$username@maas"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Display installation note
|
||||
db_input low maas/installation-note || true
|
||||
db_go
|
||||
|
||||
fi
|
||||
|
||||
systemctl enable maas-regiond >/dev/null || true
|
||||
systemctl restart maas-regiond >/dev/null || true
|
||||
invoke-rc.d apache2 restart || true
|
||||
|
||||
if [ -f /lib/systemd/system/maas-rackd.service ]; then
|
||||
systemctl restart maas-rackd >/dev/null || true
|
||||
fi
|
||||
|
||||
db_stop
|
1
maas/templates/var/_secret.tpl
Normal file
1
maas/templates/var/_secret.tpl
Normal file
@ -0,0 +1 @@
|
||||
3858f62230ac3c915f300c664312c63f
|
@ -3,8 +3,8 @@
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
images:
|
||||
maas_region: quay.io/attcomdev/maas-region:1.0.1
|
||||
maas_rack: quay.io/attcomdev/maas-rack:1.0.1
|
||||
maas_region: quay.io/attcomdev/maas-region:2.1.2-1
|
||||
maas_rack: quay.io/attcomdev/maas-rack:2.1.2
|
||||
|
||||
labels:
|
||||
node_selector_key: openstack-control-plane
|
||||
@ -17,3 +17,5 @@ network:
|
||||
service_gui_target: 80
|
||||
service_proxy: 8000
|
||||
service_proxy_target: 8000
|
||||
|
||||
service_name: maas-region-ui
|
||||
|
Loading…
Reference in New Issue
Block a user