Add image cache sidecar

- If conf.cache.enabled is true, deploy a sidecar container
  in the region pod with a simplestreams repo populated w/ a Ubuntu image
- If conf.cache.enabled is true, configure MaaS to source the image
  from the sidecar
- Update README

Closes #1

Change-Id: I968614d6fb7ca86589dc6e2efd1f66ae920d03a8
This commit is contained in:
Scott Hussey
2017-11-30 10:15:44 -06:00
parent d3b4cc974f
commit 08c1da5be1
9 changed files with 165 additions and 60 deletions

View File

@@ -49,6 +49,13 @@ function configure_dns {
maas ${ADMIN_USERNAME} maas set-config name=upstream_dns value=${MAAS_DNS_SERVERS}
}
function configure_boot_sources {
if [[ $USE_IMAGE_CACHE == 'true' ]]
then
maas ${ADMIN_USERNAME} boot-source update 1 url=http://localhost:8888/maas/images/ephemeral-v3/daily/
fi
}
KEY=$(maas-region apikey --username=${ADMIN_USERNAME})
maas login ${ADMIN_USERNAME} ${MAAS_ENDPOINT} $KEY
@@ -57,6 +64,7 @@ configure_ntp
configure_dns
# make call to import images
configure_boot_sources
maas ${ADMIN_USERNAME} boot-resources import
# see if we can find > 0 images
sleep ${RETRY_TIMER}

View File

@@ -0,0 +1,18 @@
#!/bin/bash
set -x
echo "register-rack-controller URL: ${MAAS_ENDPOINT}"
# register forever
while [ 1 ];
do
if maas-rack register --url=${MAAS_ENDPOINT} --secret="${MAAS_REGION_SECRET}";
then
echo "Successfully registered with MaaS Region Controller"
break
else
echo "Unable to register with ${MAAS_ENDPOINT}... will try again"
sleep 10
fi;
done;

View File

@@ -13,6 +13,7 @@ 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 .Values.manifests.rack_deployment }}
{{- if empty .Values.conf.maas.url.maas_url -}}
{{- tuple "maas_region_ui" "default" "region_ui" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | set .Values.conf.maas.url "maas_url" | quote | trunc 0 -}}
{{- end -}}
@@ -86,3 +87,4 @@ spec:
name: maas-etc
defaultMode: 0444
{{ if $mounts_maas_rack.volumes }}{{ toYaml $mounts_maas_rack.volumes | indent 8 }}{{ end }}
{{- end }}

View File

@@ -37,6 +37,8 @@ spec:
image: {{ .Values.images.tags.maas_region }}
imagePullPolicy: {{ .Values.images.pull_policy }}
env:
- name: USE_IMAGE_CACHE
value: {{ .Values.conf.cache.enabled | quote }}
- name: JOB_TIMEOUT
value: {{ .Values.jobs.import_boot_resources.timeout | quote }}
- name: ADMIN_USERNAME

View File

@@ -8,6 +8,7 @@ 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
app: maas-region
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
@@ -35,7 +36,7 @@ spec:
{{ end }}
name: proxy
selector:
app: maas-region
{{ tuple $envAll "maas" "region" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
{{ if .Values.network.proxy.node_port.enabled }}
type: NodePort
{{ end }}

View File

@@ -1,19 +1,18 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
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.
*/}}
# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
#
# 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 .Values.manifests.region_statefulset }}
{{- $envAll := . }}
{{- $dependencies := .Values.dependencies.region_controller }}
{{- $mounts_maas_region := .Values.pod.mounts.maas_region.maas_region }}
@@ -29,7 +28,7 @@ spec:
template:
metadata:
labels:
app: maas-region
{{ tuple $envAll "maas" "region" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
annotations:
spec:
affinity:
@@ -39,47 +38,52 @@ spec:
initContainers:
{{ tuple $envAll $dependencies $mounts_maas_region_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: maas-region
image: {{ .Values.images.tags.maas_region }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{ tuple $envAll $envAll.Values.pod.resources.maas_region | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
ports:
- name: r-ui
containerPort: {{ .Values.network.port.region_container }}
readinessProbe:
tcpSocket:
port: {{ .Values.network.port.region_container }}
securityContext:
privileged: true
command:
- /tmp/start.sh
volumeMounts:
- name: maas-region-secret
mountPath: /var/lib/maas/secret
subPath: REGION_SECRET
readOnly: true
- name: maas-etc
mountPath: /etc/bind/named.conf.options
subPath: named.conf.options
readOnly: true
- name: maas-etc
mountPath: /etc/maas/regiond.conf
subPath: regiond.conf
readOnly: true
{{- if .Values.conf.curtin.override }}
- name: maas-etc
mountPath: /etc/maas/preseeds/curtin_userdata
subPath: curtin_userdata
readOnly: true
{{- if .Values.conf.cache.enabled }}
- name: maas-cache
image: {{ .Values.images.tags.maas_cache }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{- end }}
- name: maas-bin
mountPath: /tmp/start.sh
subPath: start.sh
readOnly: true
- name: maas-etc
mountPath: /etc/nsswitch.conf
subPath: nsswitch.conf
readOnly: true
- name: maas-region
image: {{ .Values.images.tags.maas_region }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{ tuple $envAll $envAll.Values.pod.resources.maas_region | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
ports:
- name: r-ui
containerPort: {{ .Values.network.port.region_container }}
readinessProbe:
tcpSocket:
port: {{ .Values.network.port.region_container }}
securityContext:
privileged: true
command:
- /tmp/start.sh
volumeMounts:
- name: maas-region-secret
mountPath: /var/lib/maas/secret
subPath: REGION_SECRET
readOnly: true
- name: maas-etc
mountPath: /etc/bind/named.conf.options
subPath: named.conf.options
readOnly: true
- name: maas-etc
mountPath: /etc/maas/regiond.conf
subPath: regiond.conf
readOnly: true
{{- if .Values.conf.curtin.override }}
- name: maas-etc
mountPath: /etc/maas/preseeds/curtin_userdata
subPath: curtin_userdata
readOnly: true
{{- end }}
- name: maas-bin
mountPath: /tmp/start.sh
subPath: start.sh
readOnly: true
- name: maas-etc
mountPath: /etc/nsswitch.conf
subPath: nsswitch.conf
readOnly: true
{{- if $mounts_maas_region.volumeMounts }}{{ toYaml $mounts_maas_region.volumeMounts | indent 12 }}{{ end }}
volumes:
- name: maas-etc
@@ -94,3 +98,5 @@ spec:
secret:
secretName: {{ .Values.secrets.maas_region.name }}
{{- if $mounts_maas_region.volumes }}{{ toYaml $mounts_maas_region.volumes | indent 8 }}{{ end }}
...
{{- end }}