Anyone here using github container registry as a O...
# office-hours
v
Anyone here using github container registry as a OCI repository with helm charts?
👀 1
a
I'm interested to know more about this.. (Dropped a msg for watch later 🙂 )
m
same. not using but interested.
v
No but aws oci using
a
Since, this sparked my interest I've done a quick POC around it. You can use
ghcr
as OCI registry for hosting your helm charts. 1. You need to generate a PAT token with following scopes
(read:org, repo, write:packages)
2. Login to ghcr via helm
CR_PAT=YOUR_TOKEN ; echo $CR_PAT | helm registry login ghcr.io/GITHUB_USERNAME -u GITHUB_USERNAME --password-stdin
3. I've used a tool
helmper
to download helm charts/images to the
ghcr
repo. It is compatible with other OCI registries too. 4. Generate helmper config and run
helmper --f config.yaml
Copy code
k8s_version: 1.27.9
import:
  enabled: true
charts:
- name: prometheus
  version: 25.8.0
  valuesFilePath: /workspace/in/values/prometheus/values.yaml # (Optional)
  repo:
    name: prometheus-community
    url: https://prometheus-community.github.io/helm-charts/
registries:
- name: ghcr
  url: ghcr.io/GITHUB_USERNAME
Helmper output:
Copy code
❯ helmper --f config.yml 

 _         _
| |_  ___ | | _____  ___  ___  ___
|   || -_|| ||     || . || -_||  _|
|_|_||___||_||_|_|_||  _||___||_|
                    |_|
version 0.1.13 (commit fb537925fa03ff2bdbef970e94ccd48eba91c86a, built at 2024-07-26T13:20:18Z)

{"time":"2024-08-08T14:16:02.546160477+05:30","level":"INFO","msg":"Updated all Helm repositories ✅"}
+---+----------+------------+---------+----------------+--------+---------+--------------------------+---------+----------------------------------+---------+
| # | TYPE     | CHART      | VERSION | LATEST VERSION | LATEST | VALUES  | SUBCHART                 | VERSION | CONDITION                        | ENABLED |
+---+----------+------------+---------+----------------+--------+---------+--------------------------+---------+----------------------------------+---------+
| 0 | Chart    | prometheus | 25.8.0  | 25.25.0        | ❌     | default |                          |         |                                  |         |
| 1 | Subchart |            |         |                |        | parent  | alertmanager             | 1.7.*   | alertmanager.enabled             | ✅      |
| 2 | Subchart |            |         |                |        | parent  | kube-state-metrics       | 5.15.*  | kube-state-metrics.enabled       | ✅      |
| 3 | Subchart |            |         |                |        | parent  | prometheus-node-exporter | 4.24.*  | prometheus-node-exporter.enabled | ✅      |
| 4 | Subchart |            |         |                |        | parent  | prometheus-pushgateway   | 2.4.*   | prometheus-pushgateway.enabled   | ✅      |
+---+----------+------------+---------+----------------+--------+---------+--------------------------+---------+----------------------------------+---------+
 100% [===============] (5/5) Parsing charts...          
+---+--------------------------+---------------+---------------------------------------------+----------------------------------------------------------------+
| # | HELM CHART               | CHART VERSION | HELM VALUE PATH                             | IMAGE                                                          |
+---+--------------------------+---------------+---------------------------------------------+----------------------------------------------------------------+
| 0 | prometheus               | 25.8.0        | server.image.repository                     | quay.io/prometheus/prometheus:v2.48.0                          |
|   |                          |               | server.image.tag                            |                                                                |
|   |                          |               | server.image.digest                         |                                                                |
| 1 | prometheus               | 25.8.0        | configmapReload.prometheus.image.digest     | quay.io/prometheus-operator/prometheus-config-reloader:v0.67.0 |
|   |                          |               | configmapReload.prometheus.image.repository |                                                                |
|   |                          |               | configmapReload.prometheus.image.tag        |                                                                |
| 2 | alertmanager             | 1.7.*         | image.repository                            | quay.io/prometheus/alertmanager:v0.26.0                        |
|   |                          |               | image.tag                                   |                                                                |
| 3 | kube-state-metrics       | 5.15.*        | image.registry                              | registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.1  |
|   |                          |               | image.repository                            |                                                                |
|   |                          |               | image.sha                                   |                                                                |
|   |                          |               | image.tag                                   |                                                                |
| 4 | prometheus-node-exporter | 4.24.*        | image.repository                            | quay.io/prometheus/node-exporter:v1.7.0                        |
|   |                          |               | image.tag                                   |                                                                |
|   |                          |               | image.digest                                |                                                                |
|   |                          |               | image.registry                              |                                                                |
| 5 | prometheus-pushgateway   | 2.4.*         | image.repository                            | quay.io/prometheus/pushgateway:v1.6.2                          |
|   |                          |               | image.tag                                   |                                                                |
+---+--------------------------+---------------+---------------------------------------------+----------------------------------------------------------------+
+---+--------------------------+---------------+----------------------------------------------------------------+------+--------+
| # | HELM CHART               | CHART VERSION | IMAGE                                                          | GHCR | IMPORT |
+---+--------------------------+---------------+----------------------------------------------------------------+------+--------+
| 0 | prometheus               | 25.8.0        | quay.io/prometheus/prometheus:v2.48.0                          | ❌   | ✅     |
| 1 | prometheus               | 25.8.0        | quay.io/prometheus-operator/prometheus-config-reloader:v0.67.0 | ❌   | ✅     |
| 2 | alertmanager             | 1.7.*         | quay.io/prometheus/alertmanager:v0.26.0                        | ❌   | ✅     |
| 3 | kube-state-metrics       | 5.15.*        | registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.1  | ❌   | ✅     |
| 4 | prometheus-node-exporter | 4.24.*        | quay.io/prometheus/node-exporter:v1.7.0                        | ❌   | ✅     |
| 5 | prometheus-pushgateway   | 2.4.*         | quay.io/prometheus/pushgateway:v1.6.2                          | ❌   | ✅     |
+---+--------------------------+---------------+----------------------------------------------------------------+------+--------+
|   |                          |               |                                                                |      | 6      |
+---+--------------------------+---------------+----------------------------------------------------------------+------+--------+
 100% [===============] (5/5) Pushing charts...         
 100% [===============] (6/6) Pushing images...
You can navigate to https://github.com/GITHUB_USERNAME?tab=packages to check your recently pushed charts/images. Alternatively, You can pull the chart locally with helm or image with docker
Copy code
helm pull oci://ghcr.io/GITHUB_USERNAME/charts/prometheus --version 25.8.0
docker pull ghcr.io/akhan4u/prometheus/prometheus:v2.48.0
For letting your package available for others to consume, change the Package Visibility to public on GitHub,
For using it on k8s cluster
Copy code
helm upgrade --install ghcr-prom oci://ghcr.io/GITHUB_USERNAME/charts/prometheus --version 25.8.0
m
Outstanding example! 👏🏾
v
🙌🏾 Will take a look at all of this over the weekend. Thanks for sharing @akhan4u!
👍 1
This is pretty cool. I don't know if i'll use it for packaging my helm charts/publishing them, but i think i'll use it for it's other features such as being able to replicate images into a registry of my choice.