Skip to content

Commit 1b2c921

Browse files
author
Leonid Podolinskiy
authored
fetch artifact from s3 (#6)
* fetch artifact for init container from s3 * adjust helm chart for artifachub.io
1 parent a0dccba commit 1b2c921

File tree

6 files changed

+191
-48
lines changed

6 files changed

+191
-48
lines changed

.github/workflows/init_container.yaml

+20-18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ on:
1515

1616
jobs:
1717
set_image_tag_variable:
18+
strategy:
19+
matrix:
20+
agents: [
21+
{file: "agent.zip", platform: "linux"},
22+
{file: "agent-alpine.zip", platform: "alpine"}
23+
]
1824
runs-on: ubuntu-latest
1925
name: Build and push Docker image
2026
steps:
@@ -33,30 +39,26 @@ jobs:
3339
with:
3440
username: ${{ secrets.DOCKERHUB_USER }}
3541
password: ${{ secrets.DOCKERHUB_PASS }}
42+
3643

37-
- name: Build and push linux container
38-
uses: docker/build-push-action@v3
44+
- name: Configure AWS credentials for artifacts bucket
45+
uses: aws-actions/configure-aws-credentials@v1
3946
with:
40-
context: .
41-
file: ./lightrun-init-agent/Dockerfile
42-
push: true
43-
tags: "lightruncom/k8s-operator-init-java-agent-linux:${{steps.set_tag.outputs.TAG_NAME}}"
44-
secrets: |
45-
GITHUB_TOKEN=${{ secrets.PRETTY_GITHUB_READ_TOKEN }}
46-
build-args: |
47-
VERSION=${{ inputs.release_tag }}
48-
FILE=agent.zip
47+
aws-access-key-id: ${{ secrets.RELEASE_ARTIFACTS_MANAGER_KEY }}
48+
aws-secret-access-key: ${{ secrets.RELEASE_ARTIFACTS_MANAGER_SECRET }}
49+
aws-region: us-east-1
50+
51+
- name: Download agent artifacts
52+
run: |
53+
aws s3 cp s3://${{ secrets.RELEASE_ARTIFACTS_BUCKET }}/artifacts/${{ inputs.release_tag }}/${{ matrix.agents.file }} ./lightrun-init-agent/
54+
4955
50-
- name: Build and push alpine container
56+
- name: Build and push ${{ matrix.agents.platform }} container
5157
uses: docker/build-push-action@v3
5258
with:
5359
context: .
5460
file: ./lightrun-init-agent/Dockerfile
5561
push: true
56-
tags: "lightruncom/k8s-operator-init-java-agent-alpine:${{steps.set_tag.outputs.TAG_NAME}}"
57-
secrets: |
58-
GITHUB_TOKEN=${{ secrets.PRETTY_GITHUB_READ_TOKEN }}
62+
tags: "lightruncom/k8s-operator-init-java-agent-${{ matrix.agents.platform }}:${{steps.set_tag.outputs.TAG_NAME}}"
5963
build-args: |
60-
VERSION=${{ inputs.release_tag }}
61-
FILE=agent-alpine.zip
62-
64+
FILE=${{ matrix.agents.file }}

.github/workflows/required_check.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Due to https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
2+
name: dummy_check
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- 'lightrun-init-agent/**'
9+
- '.github/**'
10+
- 'docs/**'
11+
- 'grafana/**'
12+
jobs:
13+
build:
14+
if: false # always skip
15+
name: Build controller and install helm chart # name have to be as the real job name
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: 'echo "No build required"'

helm-chart/Chart.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ description: A Helm chart for Lightrun k8s operator
1010
# a dependency of application charts to inject those utilities and functions into the rendering
1111
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
1212
type: application
13+
icon: https://lightrun-public.s3.amazonaws.com/img/lightrun-logo.png
1314

1415
## Kubeversion due to "seccompProfile" in the controller deployment
1516
kubeVersion: ">= 1.19.0"
@@ -18,3 +19,61 @@ kubeVersion: ">= 1.19.0"
1819
# to the chart and its templates, including the app version.
1920
# Versions are expected to follow Semantic Versioning (https://semver.org/)
2021
version: 0.1.0 # Will be updated by CI pipeline
22+
23+
24+
25+
# ArtifactHub.io annotations
26+
annotations:
27+
artifacthub.io/crds: |
28+
- kind: LightrunJavaAgent
29+
version: v1beta
30+
name: lightrunjavaagent
31+
shortName: lrja
32+
description: Custom resource describing Lightrun agent version, configuration and deployment that will be patched. Dependend on secret with few Lightrun key
33+
artifacthub.io/crdsExamples: |
34+
apiVersion: agents.lightrun.com/v1beta
35+
kind: LightrunJavaAgent
36+
metadata:
37+
name: example-cr
38+
spec:
39+
initContainer:
40+
image: "lightruncom/k8s-operator-init-java-agent-linux:1.8.5-init.1"
41+
sharedVolumeName: lightrun-agent-init
42+
sharedVolumeMountPath: "/lightrun"
43+
deploymentName: app
44+
secretName: lightrun-secrets
45+
serverHostname: app.lightrun.com
46+
agentEnvVarName: JAVA_TOOL_OPTIONS
47+
agentConfig:
48+
max_log_cpu_cost: "2"
49+
agentTags:
50+
- operator
51+
- example
52+
- 1.8.3
53+
containerSelector:
54+
- app
55+
---
56+
apiVersion: v1
57+
metadata:
58+
name: lightrun-secrets
59+
stringData:
60+
lightrun_key: <lightrun_key_from_ui>
61+
pinned_cert_hash: <pinned_cert_hash>
62+
kind: Secret
63+
type: Opaque
64+
65+
artifacthub.io/license: Apache-2.0
66+
artifacthub.io/links: |
67+
- name: Operator repo
68+
url: https://github.com/lightrun-platform/lightrun-k8s-operator
69+
- name: CR example with explanation
70+
url: https://github.com/lightrun-platform/lightrun-k8s-operator/blob/main/examples/lightrunjavaagent.yaml
71+
artifacthub.io/maintainers: |
72+
- name: Lightrun devops team
73+
74+
- name: LeonidP
75+
76+
artifacthub.io/operator: "true"
77+
artifacthub.io/operatorCapabilities: Basic Install
78+
artifacthub.io/prerelease: "false"
79+

helm-chart/README.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# lightrun-k8s-operator
2+
3+
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
4+
5+
A Helm chart for Lightrun k8s operator
6+
7+
## Requirements
8+
9+
Kubernetes: `>= 1.19.0`
10+
11+
12+
[Helm chart](../helm-chart/) is available in repository branch `helm-repo`
13+
- Add the repo to your Helm repository list
14+
```sh
15+
helm repo add lightrun-k8s-operator https://lightrun-platform.github.io/lightrun-k8s-operator
16+
```
17+
18+
- Install the Helm chart:
19+
> _Using default [values](../helm-chart/values.yaml)_
20+
21+
```sh
22+
helm install lightrun-k8s-operator/lightrun-k8s-operator -n lightrun-operator --create-namespace
23+
```
24+
25+
> _Using custom values file_
26+
27+
```sh
28+
helm install lightrun-k8s-operator/lightrun-k8s-operator -f <values file> -n lightrun-operator --create-namespace
29+
```
30+
> `helm upgrade --install` or `helm install --dry-run` may not work properly due to limitations of how Helm work with CRDs.
31+
You can find more info [here](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/)
32+
33+
34+
- Uninstall the Helm chart.
35+
```sh
36+
helm delete lightrun-k8s-operator
37+
```
38+
> `CRDs` will not be deleted due to Helm CRDs limitations. You can learn more about the limitations [here](https://helm.sh/docs/topics/charts/#limitations-on-crds).
39+
40+
### Chart version vs controller version
41+
For the sake of simplicity, we are keeping the convention of the same version for both the controller image and the Helm chart. This helps to ensure that controller actions are aligned with CRDs preventing failed resource validation errors.
42+
43+
44+
## Values
45+
46+
| Key | Type | Default | Description |
47+
|-----|------|---------|-------------|
48+
| controllerManager.kubeRbacProxy.image.repository | string | `"gcr.io/kubebuilder/kube-rbac-proxy"` | |
49+
| controllerManager.kubeRbacProxy.image.tag | string | `"v0.11.0"` | |
50+
| controllerManager.kubeRbacProxy.resources.limits.cpu | string | `"500m"` | |
51+
| controllerManager.kubeRbacProxy.resources.limits.memory | string | `"128Mi"` | |
52+
| controllerManager.kubeRbacProxy.resources.requests.cpu | string | `"5m"` | |
53+
| controllerManager.kubeRbacProxy.resources.requests.memory | string | `"64Mi"` | |
54+
| controllerManager.manager.image.repository | string | `"lightruncom/lightrun-k8s-operator"` | |
55+
| controllerManager.manager.image.tag | string | `"latest"` | For simplicity of version compatibilities we are keeping the same controller and chart versions So the most safe approach is to use same version as the Chart. When installing chart from the helm repo, every helm package version will have controller image set to chart version |
56+
| controllerManager.manager.nodeSelector | object | `{}` | |
57+
| controllerManager.manager.resources.limits.cpu | string | `"500m"` | |
58+
| controllerManager.manager.resources.limits.memory | string | `"128Mi"` | |
59+
| controllerManager.manager.resources.requests.cpu | string | `"10m"` | |
60+
| controllerManager.manager.resources.requests.memory | string | `"64Mi"` | |
61+
| controllerManager.manager.tolerations | list | `[]` | |
62+
| controllerManager.replicas | int | `1` | |
63+
| managerConfig.controllerManagerConfigYaml.health.healthProbeBindAddress | string | `":8081"` | |
64+
| managerConfig.controllerManagerConfigYaml.leaderElection.leaderElect | bool | `true` | |
65+
| managerConfig.controllerManagerConfigYaml.leaderElection.resourceName | string | `"5b425f09.lightrun.com"` | |
66+
| managerConfig.controllerManagerConfigYaml.metrics.bindAddress | string | `"127.0.0.1:8080"` | |
67+
| managerConfig.controllerManagerConfigYaml.webhook.port | int | `9443` | |
68+
| managerConfig.logLevel | string | `"info"` | Log level: 1 - 5 Higher number - more logs Documentation of logr module https://pkg.go.dev/github.com/go-logr/[email protected]#hdr-Verbosity On level info (0) (default) you'll see only deployments that are being added or deleted and errors On level 1 you'll see 1 additional log per every successful reconciliation loop run On level 2 you'll see all debug prints with intermediate steps while patching deployment per every reconciliation loop run |
69+
| managerConfig.operatorScope | object | `{"namespacedScope":false,"namespaces":["default"]}` | Operator may work in 2 scopes: cluster and namespaced Cluster scope will give permissions to operator to watch and patch deployment in the whole cluster With namespaced scope you need to provide list of namespaces that operator will be able to watch. Namespaced scope implemented by both controller code and creation of the appropriate Roles by the chart Any change to the list of namespaces will cause restart of the operator controller pod. |
70+
| metricsService | object | `{"ports":[{"name":"https","port":8443,"protocol":"TCP","targetPort":8443}],"type":"ClusterIP"}` | Metrics service for prometheus compatible poller |
71+
| nameOverride | string | `"lightrun-k8s-operator"` | |
72+
73+
----------------------------------------------
74+
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)

helm-chart/values.yaml

+15-15
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ controllerManager:
2020
manager:
2121
image:
2222
repository: lightruncom/lightrun-k8s-operator
23-
## For simplicity of version compatibilities we are keeping the same controller and chart versions
24-
## So the most safe approach is to use same version as the Chart.
25-
## When installing chart from the helm repo, every helm package version will have controller image set to chart version
23+
# -- For simplicity of version compatibilities we are keeping the same controller and chart versions
24+
# So the most safe approach is to use same version as the Chart.
25+
# When installing chart from the helm repo, every helm package version will have controller image set to chart version
2626
tag: latest
2727
resources:
2828
limits:
@@ -51,12 +51,12 @@ controllerManager:
5151

5252
## Controller configuration
5353
managerConfig:
54-
## Log level: 1 - 5
55-
## Higher number - more logs
56-
## Documentation of logr module https://pkg.go.dev/github.com/go-logr/[email protected]#hdr-Verbosity
57-
## On level info (0) (default) you'll see only deployments that are being added or deleted and errors
58-
## On level 1 you'll see 1 additional log per every successful reconciliation loop run
59-
## On level 2 you'll see all debug prints with intermediate steps while patching deployment per every reconciliation loop run
54+
# -- Log level: 1 - 5
55+
# Higher number - more logs
56+
# Documentation of logr module https://pkg.go.dev/github.com/go-logr/[email protected]#hdr-Verbosity
57+
# On level info (0) (default) you'll see only deployments that are being added or deleted and errors
58+
# On level 1 you'll see 1 additional log per every successful reconciliation loop run
59+
# On level 2 you'll see all debug prints with intermediate steps while patching deployment per every reconciliation loop run
6060
logLevel: info
6161

6262
## Default values of the container inside pod. In most cases you don't need to change those
@@ -70,17 +70,17 @@ managerConfig:
7070
bindAddress: 127.0.0.1:8080
7171
webhook:
7272
port: 9443
73-
## Operator may work in 2 scopes: cluster and namespaced
74-
## Cluster scope will give permissions to operator to watch and patch deployment in the whole cluster
75-
## With namespaced scope you need to provide list of namespaces that operator will be able to watch.
76-
## Namespaced scope implemented by both controller code and creation of the appropriate Roles by the chart
77-
## Any change to the list of namespaces will cause restart of the operator controller pod.
73+
# -- Operator may work in 2 scopes: cluster and namespaced
74+
# Cluster scope will give permissions to operator to watch and patch deployment in the whole cluster
75+
# With namespaced scope you need to provide list of namespaces that operator will be able to watch.
76+
# Namespaced scope implemented by both controller code and creation of the appropriate Roles by the chart
77+
# Any change to the list of namespaces will cause restart of the operator controller pod.
7878
operatorScope:
7979
namespaces:
8080
- default
8181
namespacedScope: false
8282

83-
## Metrics service for prometheus compatible poller
83+
# -- Metrics service for prometheus compatible poller
8484
metricsService:
8585
ports:
8686
- name: https

lightrun-init-agent/Dockerfile

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
FROM --platform=linux/amd64 alpine:latest
22

3-
ARG VERSION
43
ARG FILE
54

6-
RUN apk --no-cache add jq \
7-
wget
8-
RUN --mount=type=secret,id=GITHUB_TOKEN \
9-
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) \
10-
export REPO="lightrun-platform/athena"; \
11-
# curl inside alpine can't properly forward cookies when downloading asset, hence wget
12-
wget -q --auth-no-challenge --header='Accept:application/octet-stream' \
13-
https://$GITHUB_TOKEN:@api.github.com/repos/$REPO/releases/assets/`wget -q -O- --auth-no-challenge --header "Accept: application/vnd.github+json" https://$GITHUB_TOKEN:@api.github.com/repos/$REPO/releases | jq ". | map(select(.tag_name == \"$VERSION\"))[0].assets | map(select(.name == \"$FILE\"))[0].id"` \
14-
-O /tmp/agent.zip; \
15-
mkdir /agent ;\
16-
unzip -o /tmp/agent.zip -d /agent ;\
17-
rm -rf /tmp/agent.zip && \
5+
COPY lightrun-init-agent/$FILE /tmp/$FILE
6+
7+
RUN unzip -o /tmp/$FILE -d /agent ;\
8+
rm -rf /tmp/$FILE && \
189
# Erase default values
1910
sed -i.bak "s|com.lightrun.secret=.*|com.lightrun.secret=|" /agent/agent.config && rm /agent/agent.config.bak && \
2011
sed -i.bak "s|pinned_certs=.*|pinned_certs=|" /agent/agent.config && rm /agent/agent.config.bak && \
21-
# In openshift UID will be dynamic per project, hence chmo and not chown
12+
# In openshift UID will be dynamic per project, hence chmod and not chown
2213
chmod -R 777 /agent
2314

2415
USER 1000
25-
2616
COPY lightrun-init-agent/update_config.sh /update_config.sh
2717

2818
CMD [ "/bin/sh", "/update_config.sh" ]

0 commit comments

Comments
 (0)