Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit ee20ea3

Browse files
eldadak8s-ci-robot
authored andcommitted
Better resource management for Artifactory (helm#3021)
* Better resource management for Artifactory (#1) * Update Artifactory version * Add resources requests and limits to all pods * Ability to set whitelist on Nginx LoadBalancer service * Support setting a custom artifactory service name (that will also be set in nginx config) * Add new parameters to README * Fix artifactory replicas reference. Hardcode database replicas to 1 * Use resource memory requests and limits in Artifactory java options * Add readinessProbe to Artifactory * Add readme on creating a Kubernetes Docker registry secret and passing it to helm * Update Artifactory Chart version to 6.2.3 * Comment out the default resources and update README on how to use them * Set Artifactory version 5.6.3 * Remove default values for Nginx resources from README
1 parent 38995da commit ee20ea3

File tree

8 files changed

+211
-35
lines changed

8 files changed

+211
-35
lines changed

stable/artifactory/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v1
22
name: artifactory
33
home: https://www.jfrog.com/artifactory/
4-
version: 6.2.2
5-
appVersion: 5.6.2
4+
version: 6.2.3
5+
appVersion: 5.6.3
66
description: Universal Repository Manager supporting all major packaging formats,
77
build tools and CI servers.
88
keywords:

stable/artifactory/README.md

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
## Chart Details
99
This chart will do the following:
1010

11-
* Deploy Artifactory-Oss
12-
* Deploy Artifactory-Pro
11+
* Deploy Artifactory-Pro (or OSS if set custom image)
12+
* Deploy a PostgreSQL database
13+
* Deploy an Nginx server
1314

1415
## Installing the Chart
1516

@@ -37,6 +38,31 @@ $ helm upgrade artifactory --namespace artifactory stable/artifactory
3738

3839
This will apply any configuration changes on your existing deployment.
3940

41+
### Artifactory memory and CPU resources
42+
The Artifactory Helm chart comes with support for configured resource requests and limits to Artifactory, Nginx and PostgreSQL. By default, these settings are commented out.
43+
It is **highly** recommended to set these so you have full control of the allocated resources and limits.
44+
Artifactory java memory parameters can (and should) also be set to match the allocated resources with `artifactory.javaOpts.xms` and `artifactory.javaOpts.xmx`.
45+
```bash
46+
# Example of setting resource requests and limits to all pods (including passing java memory settings to Artifactory)
47+
$ helm install --name artifactory \
48+
--set artifactory.resources.requests.cpu="500m" \
49+
--set artifactory.resources.limits.cpu="2" \
50+
--set artifactory.resources.requests.memory="1Gi" \
51+
--set artifactory.resources.limits.memory="4Gi" \
52+
--set artifactory.javaOpts.xms="1g" \
53+
--set artifactory.javaOpts.xmx="4g" \
54+
--set database.resources.requests.cpu="200m" \
55+
--set database.resources.limits.cpu="1" \
56+
--set database.resources.requests.memory="500Mi" \
57+
--set database.resources.limits.memory="1Gi" \
58+
--set nginx.resources.requests.cpu="100m" \
59+
--set nginx.resources.limits.cpu="250m" \
60+
--set nginx.resources.requests.memory="250Mi" \
61+
--set nginx.resources.limits.memory="500Mi" \
62+
stable/artifactory
63+
```
64+
Get more details on configuring Artifactory in the [official documentation](https://www.jfrog.com/confluence/).
65+
4066
### Customizing Database password
4167
You can override the specified database password (set in [values.yaml](values.yaml)), by passing it as a parameter in the install command line
4268
```bash
@@ -49,22 +75,35 @@ You can customise other parameters in the same way, by passing them on `helm ins
4975
```bash
5076
$ helm delete --purge artifactory
5177
```
52-
5378
This will completely delete your Artifactory Pro deployment.
5479
**IMPORTANT:** This will also delete your data volumes. You will loose all data!
5580

81+
82+
### Custom Docker registry for your images
83+
If you need to pull your Docker images from a private registry, you need to create a
84+
[Kubernetes Docker registry secret](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) and pass it to helm
85+
```bash
86+
# Create a Docker registry secret called 'regsecret'
87+
$ kubectl create secret docker-registry regsecret --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
88+
```
89+
Once created, you pass it to `helm`
90+
```bash
91+
$ helm install --name artifactory --set imagePullSecrets=regsecret stable/artifactory
92+
```
93+
5694
## Configuration
5795

5896
The following tables lists the configurable parameters of the artifactory chart and their default values.
5997

6098
| Parameter | Description | Default |
6199
|---------------------------|-----------------------------------|----------------------------------------------------------|
62-
| `database.name` | Database name | `postgresql` |
63-
| `database.replicaCount` | Database replica count | `1` |
64-
| `database.env.type` | Database type | `postgresql` |
65-
| `database.env.name` | Database name | `artifactory` |
66-
| `database.env.user` | Database username | `artifactory` |
67-
| `database.env.pass` | Database password | `Randomly generated` |
100+
| `imagePullSecrets` | Docker registry pull secret | |
101+
| `database.name` | Database name | `postgresql` |
102+
| `database.replicaCount` | Database replica count | `1` |
103+
| `database.env.type` | Database type | `postgresql` |
104+
| `database.env.name` | Database name | `artifactory` |
105+
| `database.env.user` | Database username | `artifactory` |
106+
| `database.env.pass` | Database password | `Randomly generated` |
68107
| `database.image.repository` | Database container image | `docker.bintray.io/postgres` |
69108
| `database.image.version` | Database container image tag | `9.5.2` |
70109
| `database.image.pullPolicy` | Container pull policy | `IfNotPresent` |
@@ -74,25 +113,38 @@ The following tables lists the configurable parameters of the artifactory chart
74113
| `database.persistence.mountPath` | Database persistence volume mount path | `"/var/lib/postgresql/data"` |
75114
| `database.persistence.enabled` | Database persistence volume enabled | `true` |
76115
| `database.persistence.accessMode` | Database persistence volume access mode | `ReadWriteOnce` |
77-
| `database.persistence.size` | Database persistence volume size | `10Gi` |
116+
| `database.persistence.size` | Database persistence volume size | `10Gi` |
117+
| `database.resources.requests.memory` | Database initial memory request | |
118+
| `database.resources.requests.cpu` | Database initial cpu request | |
119+
| `database.resources.limits.memory` | Database memory limit | |
120+
| `database.resources.limits.cpu` | Database cpu limit | |
78121
| `artifactory.name` | Artifactory name | `artifactory` |
79122
| `artifactory.replicaCount` | Replica count for Artifactory deployment| `1` |
80123
| `artifactory.image.pullPolicy` | Container pull policy | `IfNotPresent` |
81124
| `artifactory.image.repository` | Container image | `docker.bintray.io/jfrog/artifactory-pro` |
82-
| `artifactory.image.version` | Container image tag | `5.6.2` |
125+
| `artifactory.image.version` | Container image tag | `5.6.3` |
126+
| `artifactory.service.name`| Artifactory service name to be set in Nginx configuration | `artifactory` |
83127
| `artifactory.service.type`| Artifactory service type | `ClusterIP` |
84128
| `artifactory.externalPort` | Artifactory service external port | `8081` |
85129
| `artifactory.internalPort` | Artifactory service internal port | `8081` |
86130
| `artifactory.persistence.mountPath` | Artifactory persistence volume mount path | `"/var/opt/jfrog/artifactory"` |
87131
| `artifactory.persistence.enabled` | Artifactory persistence volume enabled | `true` |
88132
| `artifactory.persistence.accessMode` | Artifactory persistence volume access mode | `ReadWriteOnce` |
89133
| `artifactory.persistence.size` | Artifactory persistence volume size | `20Gi` |
134+
| `artifactory.resources.requests.memory` | Artifactory initial memory request | |
135+
| `artifactory.resources.requests.cpu` | Artifactory initial cpu request | |
136+
| `artifactory.resources.limits.memory` | Artifactory memory limit | |
137+
| `artifactory.resources.limits.cpu` | Artifactory cpu limit | |
138+
| `artifactory.javaOpts.xms` | Artifactory java Xms size | |
139+
| `artifactory.javaOpts.xmx` | Artifactory java Xms size | |
140+
| `artifactory.javaOpts.other` | Artifactory additional java options | |
90141
| `nginx.name` | Nginx name | `nginx` |
91142
| `nginx.replicaCount` | Nginx replica count | `1` |
92143
| `nginx.image.repository` | Container image | `docker.bintray.io/jfrog/nginx-artifactory-pro` |
93144
| `nginx.image.pullPolicy` | Container pull policy | `IfNotPresent` |
94-
| `nginx.image.version` | Container image tag | `5.6.2` |
145+
| `nginx.image.version` | Container image tag | `5.6.3` |
95146
| `nginx.service.type`| Nginx service type | `LoadBalancer` |
147+
| `nginx.service.loadBalancerSourceRanges`| Nginx service array of IP CIDR ranges to whitelist (only when service type is LoadBalancer) | |
96148
| `nginx.externalPortHttp` | Nginx service external port | `80` |
97149
| `nginx.internalPortHttp` | Nginx service internal port | `80` |
98150
| `nginx.externalPortHttps` | Nginx service external port | `443` |
@@ -103,6 +155,10 @@ The following tables lists the configurable parameters of the artifactory chart
103155
| `nginx.persistence.enabled` | Nginx persistence volume enabled | `true` |
104156
| `nginx.persistence.accessMode` | Nginx persistence volume access mode | `ReadWriteOnce` |
105157
| `nginx.persistence.size` | Nginx persistence volume size | `5Gi` |
158+
| `nginx.resources.requests.memory` | Nginx initial memory request | |
159+
| `nginx.resources.requests.cpu` | Nginx initial cpu request | |
160+
| `nginx.resources.limits.memory` | Nginx memory limit | |
161+
| `nginx.resources.limits.cpu` | Nginx cpu limit | |
106162

107163
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
108164

stable/artifactory/templates/artifactory-deployment.yaml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,35 @@ metadata:
99
heritage: {{ .Release.Service }}
1010
release: {{ .Release.Name }}
1111
spec:
12-
replicas: {{ .Values.artReplicaCount }}
12+
replicas: {{ .Values.artifactory.replicaCount }}
1313
template:
1414
metadata:
1515
labels:
1616
app: {{ template "artifactory.name" . }}
1717
component: "{{ .Values.artifactory.name }}"
1818
release: {{ .Release.Name }}
1919
spec:
20+
{{- if .Values.imagePullSecrets }}
21+
imagePullSecrets:
22+
- name: {{ .Values.imagePullSecrets }}
23+
{{- end }}
2024
initContainers:
2125
- name: "remove-lost-found"
2226
image: "{{ .Values.initContainerImage }}"
2327
imagePullPolicy: {{ .Values.artifactory.image.pullPolicy }}
2428
command:
25-
- "rm"
26-
- "-rf"
27-
- "{{ .Values.artifactory.persistence.mountPath }}/lost+found"
29+
- 'sh'
30+
- '-c'
31+
- 'rm -rfv {{ .Values.artifactory.persistence.mountPath }}/lost+found'
2832
volumeMounts:
2933
- mountPath: {{ .Values.artifactory.persistence.mountPath | quote }}
3034
name: artifactory-volume
35+
- name: "wait-for-db"
36+
image: "{{ .Values.initContainerImage }}"
37+
command:
38+
- 'sh'
39+
- '-c'
40+
- 'until nc -z -w 2 {{ template "artifactory.database.name" . }} {{ .Values.database.externalPort }} && echo database ok; do sleep 2; done'
3141
containers:
3242
- name: {{ .Values.artifactory.name }}
3343
image: "{{ .Values.artifactory.image.repository }}:{{ .Values.artifactory.image.version }}"
@@ -44,11 +54,38 @@ spec:
4454
key: artifactory-database-password
4555
- name: DB_HOST
4656
value: {{ template "artifactory.database.name" . }}
57+
- name: EXTRA_JAVA_OPTIONS
58+
value: "
59+
{{- if .Values.artifactory.javaOpts.other }}
60+
{{ .Values.artifactory.javaOpts.other }}
61+
{{- end}}
62+
{{- if .Values.artifactory.javaOpts.xms }}
63+
-Xms{{ .Values.artifactory.javaOpts.xms }}
64+
{{- end}}
65+
{{- if .Values.artifactory.javaOpts.xmx }}
66+
-Xmx{{ .Values.artifactory.javaOpts.xmx }}
67+
{{- end}}
68+
"
4769
ports:
4870
- containerPort: {{ .Values.artifactory.internalPort }}
4971
volumeMounts:
50-
- mountPath: {{ .Values.artifactory.persistence.mountPath | quote }}
51-
name: artifactory-volume
72+
- name: artifactory-volume
73+
mountPath: {{ .Values.artifactory.persistence.mountPath | quote }}
74+
resources:
75+
{{ toYaml .Values.artifactory.resources | indent 10 }}
76+
readinessProbe:
77+
httpGet:
78+
path: '/artifactory/webapp/#/login'
79+
port: 8081
80+
initialDelaySeconds: 60
81+
periodSeconds: 10
82+
failureThreshold: 10
83+
livenessProbe:
84+
httpGet:
85+
path: '/artifactory/webapp/#/login'
86+
port: 8081
87+
initialDelaySeconds: 180
88+
periodSeconds: 10
5289
volumes:
5390
- name: artifactory-volume
5491
{{- if .Values.artifactory.persistence.enabled }}

stable/artifactory/templates/artifactory-service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: {{ template "artifactory.artifactory.name" . }}
4+
name: {{ .Values.artifactory.service.name }}
55
labels:
66
app: {{ template "artifactory.name" . }}
77
chart: {{ .Chart.Name }}-{{ .Chart.Version }}

stable/artifactory/templates/nginx-deployment.yaml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,50 @@ spec:
1717
component: "{{ .Values.nginx.name }}"
1818
release: {{ .Release.Name }}
1919
spec:
20+
{{- if .Values.imagePullSecrets }}
21+
imagePullSecrets:
22+
- name: {{ .Values.imagePullSecrets }}
23+
{{- end }}
2024
initContainers:
2125
- name: "remove-lost-found"
2226
image: "{{ .Values.initContainerImage }}"
2327
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
2428
command:
25-
- "rm"
26-
- "-rf"
27-
- "{{ .Values.nginx.persistence.mountPath }}/lost+found"
29+
- '/bin/sh'
30+
- '-c'
31+
- 'rm -rfv {{ .Values.nginx.persistence.mountPath }}/lost+found'
2832
volumeMounts:
2933
- mountPath: {{ .Values.nginx.persistence.mountPath | quote }}
3034
name: nginx-volume
3135
containers:
3236
- name: {{ .Values.nginx.name }}
3337
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.version }}"
3438
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
39+
lifecycle:
40+
postStart:
41+
exec:
42+
command:
43+
- '/bin/sh'
44+
- '-c'
45+
- >
46+
until [ -f /etc/nginx/conf.d/artifactory.conf ]; do sleep 1; done;
47+
sed -i -e 's,proxy_pass .*,proxy_pass {{ .Values.nginx.env.artUrl }}/;,g' \
48+
-e 's,server_name .*,server_name ~(?<repo>.+)\\.{{ .Values.artifactory.service.name }} {{ .Values.artifactory.service.name }};,g' \
49+
/etc/nginx/conf.d/artifactory.conf;
50+
sleep 5; nginx -s reload; touch /var/log/nginx/conf.done
3551
env:
3652
- name: ART_BASE_URL
37-
value: {{ .Values.nginx.env.artUrl }}
53+
value: "{{ .Values.nginx.env.artUrl }}"
3854
- name: SSL
3955
value: "{{ .Values.nginx.env.ssl }}"
4056
ports:
4157
- containerPort: {{ .Values.nginx.internalPortHttp }}
4258
- containerPort: {{ .Values.nginx.internalPortHttps }}
4359
volumeMounts:
44-
- mountPath: {{ .Values.nginx.persistence.mountPath | quote }}
45-
name: nginx-volume
60+
- name: nginx-volume
61+
mountPath: {{ .Values.nginx.persistence.mountPath | quote }}
62+
resources:
63+
{{ toYaml .Values.nginx.resources | indent 10 }}
4664
volumes:
4765
- name: nginx-volume
4866
{{- if .Values.nginx.persistence.enabled }}

stable/artifactory/templates/nginx-service.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ metadata:
1010
release: {{ .Release.Name }}
1111
spec:
1212
type: {{ .Values.nginx.service.type }}
13+
{{- if eq .Values.nginx.service.type "LoadBalancer" }}
14+
externalTrafficPolicy: Local
15+
{{- end }}
16+
{{- if .Values.nginx.service.loadBalancerSourceRanges }}
17+
loadBalancerSourceRanges:
18+
{{ toYaml .Values.nginx.service.loadBalancerSourceRanges | indent 4 }}
19+
{{- end }}
1320
ports:
1421
- port: {{ .Values.nginx.externalPortHttp }}
1522
targetPort: {{ .Values.nginx.internalPortHttp }}

stable/artifactory/templates/postgresql-deployment.yaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
heritage: {{ .Release.Service }}
1010
release: {{ .Release.Name }}
1111
spec:
12-
replicas: {{ .Values.replicaCount }}
12+
replicas: 1
1313
template:
1414
metadata:
1515
labels:
@@ -22,9 +22,9 @@ spec:
2222
image: "{{ .Values.initContainerImage }}"
2323
imagePullPolicy: "{{ .Values.database.image.pullPolicy }}"
2424
command:
25-
- "rm"
26-
- "-rf"
27-
- "{{ .Values.database.persistence.mountPath }}/lost+found"
25+
- 'sh'
26+
- '-c'
27+
- 'rm -rf {{ .Values.database.persistence.mountPath }}/lost+found'
2828
volumeMounts:
2929
- mountPath: {{ .Values.database.persistence.mountPath | quote }}
3030
name: postgresql-volume
@@ -47,6 +47,26 @@ spec:
4747
volumeMounts:
4848
- mountPath: {{ .Values.database.persistence.mountPath | quote }}
4949
name: postgresql-volume
50+
resources:
51+
{{ toYaml .Values.database.resources | indent 10 }}
52+
livenessProbe:
53+
exec:
54+
command:
55+
- sh
56+
- -c
57+
- exec pg_isready
58+
initialDelaySeconds: 60
59+
timeoutSeconds: 5
60+
failureThreshold: 6
61+
readinessProbe:
62+
exec:
63+
command:
64+
- sh
65+
- -c
66+
- exec pg_isready
67+
initialDelaySeconds: 30
68+
timeoutSeconds: 3
69+
periodSeconds: 5
5070
volumes:
5171
- name: postgresql-volume
5272
{{- if .Values.database.persistence.enabled }}

0 commit comments

Comments
 (0)