Browse Source

AiaP - Develop a method to support caching on a remote node

- Adds PV for local caching. This allows us to also use PV
        in other clusters like AKS.
    - Moves artifacts and caching files into /opt/aiap-files/artifacts
        and /opt/aiap-files/caching so we only have one PV

Relates-To: #645

Change-Id: I84172778df66bee8a833b13d5b740a6cf45220c2
changes/80/820580/4
Walter Wahlstedt 6 months ago
parent
commit
61c18d9359
  1. 5
      tools/airship-in-a-pod/README.md
  2. 4
      tools/airship-in-a-pod/base/Dockerfile
  3. 3
      tools/airship-in-a-pod/examples/airshipctl/kustomization.yaml
  4. 47
      tools/airship-in-a-pod/examples/airshipctl/pv.yaml
  5. 13
      tools/airship-in-a-pod/examples/airshipctl/replacements.yaml
  6. 52
      tools/airship-in-a-pod/examples/base/airship-in-a-pod.yaml

5
tools/airship-in-a-pod/README.md

@ -163,14 +163,15 @@ Airship-in-a-pod produces the following outputs:
* A tarball containing the generated ephemeral ISO, as well as the
configuration used during generation.
These artifacts are placed at `ARTIFACTS_DIR` (defaults to `/opt/aiap-artifacts`).
These artifacts are placed at `ARTIFACTS_DIR` (defaults to `/opt/aiap-files/artifacts`).
## Caching
#TODO: Need to review this.
As it can be cumbersome and time-consuming to build and rebuild binaries and
images, some options are made available for caching. A developer may re-use
artifacts from previous runs (or provide their own) by placing them in
`CACHE_DIR` (defaults to `/opt/aiap-cache`). Special care is needed for the
`CACHE_DIR` (defaults to `/opt/aiap-files/cache`). Special care is needed for the
caching:
* If using a cached `airshipctl`, the `airshipctl` binary must be stored in the

4
tools/airship-in-a-pod/base/Dockerfile

@ -4,10 +4,10 @@ FROM ${BASE_IMAGE}
SHELL ["bash", "-exc"]
ENV DEBIAN_FRONTEND noninteractive
ARG CACHE_DIR=/opt/aiap-cache
ARG CACHE_DIR=/opt/aiap-files/cache
ENV CACHE_DIR=$CACHE_DIR
ARG ARTIFACTS_DIR=/opt/aiap-artifacts
ARG ARTIFACTS_DIR=/opt/aiap-files/artifacts
ENV ARTIFACTS_DIR=$ARTIFACTS_DIR
# Update distro and install common reqs

3
tools/airship-in-a-pod/examples/airshipctl/kustomization.yaml

@ -15,6 +15,9 @@ kind: Kustomization
bases:
- ../base
resources:
- pv.yaml
patchesJson6902:
- target:
version: v1 # apiVersion

47
tools/airship-in-a-pod/examples/airshipctl/pv.yaml

@ -0,0 +1,47 @@
# 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: PersistentVolume
metadata:
name: aiap-pv-files-volume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Delete
storageClassName: standard
local:
path: /var/local-path-provisioner
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- kind-control-plane
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: aiap-pv-files-claim
spec:
storageClassName: standard
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi

13
tools/airship-in-a-pod/examples/airshipctl/replacements.yaml

@ -61,28 +61,29 @@
# that it should be the same across containers
- op: replace
path: "/spec/containers/4/env/2/value"
value: /opt/aiap-artifacts
value: /opt/aiap-files/artifacts
- op: replace
path: "/spec/containers/5/env/1/value"
value: /opt/aiap-artifacts
value: /opt/aiap-files/artifacts
- op: replace
path: "/spec/containers/6/env/1/value"
value: /opt/aiap-artifacts
value: /opt/aiap-files/artifacts
# This is the location on the host machine of the cache directory. Note that it
# should be the same across containers
- op: replace
path: "/spec/containers/4/env/0/value"
value: /opt/aiap-cache
value: /opt/aiap-files/cache
- op: replace
path: "/spec/containers/5/env/0/value"
value: /opt/aiap-cache
value: /opt/aiap-files/cache
- op: replace
path: "/spec/containers/6/env/0/value"
value: /opt/aiap-cache
value: /opt/aiap-files/cache
# Set true to use a cached airshipctl binary
- op: replace
path: "/spec/containers/4/env/1/value"
# value: $(USE_CACHED_AIRSHIPCTL)
value: "false"
# Set true to use a cached ephemeral iso
- op: replace

52
tools/airship-in-a-pod/examples/base/airship-in-a-pod.yaml

@ -223,11 +223,11 @@ spec:
- /entrypoint.sh
env:
- name: CACHE_DIR
value: /opt/aiap-cache
value: /opt/aiap-files/cache
- name: USE_CACHED_AIRSHIPCTL
value: "false"
- name: ARTIFACTS_DIR
value: /opt/aiap-artifacts
value: /opt/aiap-files/artifacts
- name: AIRSHIPCTL_REPO_URL
value: https://opendev.org/airship/airshipctl
- name: AIRSHIPCTL_REPO_REF
@ -245,10 +245,8 @@ spec:
volumeMounts:
- name: tmp
mountPath: /tmp
- name: cache
mountPath: /opt/aiap-cache
- name: artifacts
mountPath: /opt/aiap-artifacts
- name: aiap-files
mountPath: /opt/aiap-files
- name: status
mountPath: /tmp/status
- name: var-run-docker
@ -269,9 +267,9 @@ spec:
- /entrypoint.sh
env:
- name: CACHE_DIR
value: /opt/aiap-cache
value: /opt/aiap-files/cache
- name: ARTIFACTS_DIR
value: /opt/aiap-artifacts
value: /opt/aiap-files/artifacts
- name: USE_PROXY
value:
- name: no_proxy
@ -281,10 +279,8 @@ spec:
- name: https_proxy
value:
volumeMounts:
- name: cache
mountPath: /opt/aiap-cache
- name: artifacts
mountPath: /opt/aiap-artifacts
- name: aiap-files
mountPath: /opt/aiap-files
- name: status
mountPath: /tmp/status
- name: tmp
@ -311,9 +307,9 @@ spec:
- /entrypoint.sh
env:
- name: CACHE_DIR
value: /opt/aiap-cache
value: /opt/aiap-files/cache
- name: ARTIFACTS_DIR
value: /opt/aiap-artifacts
value: /opt/aiap-files/artifacts
- name: USE_CACHED_ISO
value: "false"
- name: AIRSHIP_CONFIG_PHASE_REPO_URL
@ -336,10 +332,8 @@ spec:
value:
volumeMounts:
- name: cache
mountPath: /opt/aiap-cache
- name: artifacts
mountPath: /opt/aiap-artifacts
- name: aiap-files
mountPath: /opt/aiap-files
- name: status
mountPath: /tmp/status
- name: tmp
@ -367,13 +361,23 @@ spec:
- name: status
mountPath: /tmp/status
initContainers:
- name: init-aiap-files
image: ubuntu:20.04
command:
- bash
- -cex
- |
mkdir -p /opt/aiap-files/artifacts
mkdir -p /opt/aiap-files/cache
volumeMounts:
- name: aiap-files
mountPath: /opt/aiap-files
volumes:
- name: cache
hostPath:
path: /opt/aiap-cache
- name: artifacts
hostPath:
path: /opt/aiap-artifacts
- name: aiap-files
persistentVolumeClaim:
claimName: aiap-pv-files-claim
- name: status
emptyDir: {}
- name: dev

Loading…
Cancel
Save