Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASM-4348: split ConfigMap feature with migration of single ConfigMap to multiple ConfigMaps as pre-upgrade process #304

Merged
merged 12 commits into from
Feb 8, 2024
Merged
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ dist/

# VS Code config
workspace.code-workspace

# cache specific
*.pyc
**__pycache__**

# removing pycharm specific
.idea
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.0] - 2024-02-08

### Changed

- CASM-4350: To address the 1MiB size limit of Kubernetes ConfigMaps, the
`cray-product-catalog` Kubernetes ConfigMap is split into multiple smaller
ConfigMaps with each product's `component_versions` data in its own ConfigMap.
Modified `create`, `modify`, `delete` and `query` feature to support
the split of single ConfigMap into multiple ConfigMaps.
- Added new argument `max_attempts` to `modify_config_map` function in
[`catalog_delete.py`](cray_product_catalog/catalog_delete.py), because we need not retry 100
times when read ConfigMap fails for a product ConfigMap.
- CASM-4504: Added label "type=cray-product-catalog" to all cray-product-catalog related ConfigMaps
- Implemented migration of cray-product-catalog ConfigMap to multiple ConfigMaps as part of pre-upgrade steps
- Added migration job to the configmap-hook

### Dependencies
- Bump `tj-actions/changed-files` from 40 to 42 ([#307](https://github.com/Cray-HPE/cray-product-catalog/pull/307), [#309](https://github.com/Cray-HPE/cray-product-catalog/pull/309))

Expand Down Expand Up @@ -443,7 +459,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Change default reviewers to CMS-core-product-support

[Unreleased]: https://github.com/Cray-HPE/cray-product-catalog/compare/v1.10.0...HEAD
[Unreleased]: https://github.com/Cray-HPE/cray-product-catalog/compare/v2.0.0...HEAD

[2.0.0]: https://github.com/Cray-HPE/cray-product-catalog/compare/v1.10.0...v2.0.0

[1.10.0]: https://github.com/Cray-HPE/cray-product-catalog/compare/v1.9.0...v1.10.0

Expand Down
40 changes: 36 additions & 4 deletions charts/cray-product-catalog/templates/configmap-hook.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
MIT License

(C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
(C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -43,10 +43,11 @@ spec:
command: ["/bin/sh"]
args:
- "-c"
- "kubectl get cm -n services cpc-backup -o yaml |
- "kubectl delete cm -n services cray-product-catalog &&
kubectl get cm -n services cpc-backup -o yaml |
yq eval '.metadata.name = \"cray-product-catalog\"' - |
yq eval 'del(.metadata.resourceVersion, .metadata.uid, .metadata.annotations, .metadata.creationTimestamp, .metadata.selfLink, .metadata.managedFields)' - |
kubectl apply -f - && kubectl delete cm -n services cpc-backup"
kubectl create -f - && kubectl delete cm -n services cpc-backup"

---
apiVersion: batch/v1
Expand All @@ -56,6 +57,7 @@ metadata:
namespace: services
annotations:
"helm.sh/hook": pre-upgrade,pre-rollback
"helm.sh/hook-weight": "2"
spec:
template:
metadata:
Expand All @@ -73,4 +75,34 @@ spec:
- "kubectl get cm -n services cray-product-catalog -o yaml |
yq eval '.metadata.name = \"cpc-backup\"' - |
yq eval 'del(.metadata.resourceVersion, .metadata.uid, .metadata.annotations, .metadata.creationTimestamp, .metadata.selfLink, .metadata.managedFields)' - |
kubectl apply -f -"
kubectl create -f -"

---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-migrate
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "1"
spec:
backoffLimit: 0
template:
spec:
containers:
- args:
- -c
- /usr/bin/catalog_migrate
command:
- /bin/sh
env:
- name: CONFIG_MAP_NAME
value: {{ .Values.migration.configMap }}
- name: CONFIG_MAP_NAMESPACE
value: {{ .Values.migration.configMapNamespace }}
image: "{{ .Values.migration.image.repository }}:{{ .Values.global.appVersion }}"
imagePullPolicy: IfNotPresent
name: migrate-catalog
restartPolicy: Never
serviceAccountName: {{ .Values.migration.serviceAccountName }}

4 changes: 3 additions & 1 deletion charts/cray-product-catalog/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
MIT License

(C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
(C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand All @@ -25,4 +25,6 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: cray-product-catalog
labels:
type: cray-product-catalog
data: null
12 changes: 11 additions & 1 deletion charts/cray-product-catalog/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand All @@ -25,3 +25,13 @@ kubectl:
image:
repository: artifactory.algol60.net/csm-docker/stable/docker-kubectl
tag: 1.19.15
migration:
image:
repository: artifactory.algol60.net/csm-docker/S-T-A-B-L-E/cray-product-catalog-update
tag: 0.0.0-docker
configMap: cray-product-catalog
configMapNamespace: services
serviceAccountName: cray-product-catalog

global:
appVersion: 0.0.0-docker
Loading
Loading