Back to Charts

JFrog Artifactory High Availability Helm Chart - DEPRECATED

stable/artifactory-ha/README.md

latest32.3 KB
Original Source

JFrog Artifactory High Availability Helm Chart - DEPRECATED

This chart is deprecated! You can find the new chart in:

bash
helm repo add jfrog https://charts.jfrog.io

Prerequisites Details

  • Kubernetes 1.8+
  • Artifactory HA license

Chart Details

This chart will do the following:

  • Deploy Artifactory highly available cluster. 1 primary node and 2 member nodes.
  • Deploy a PostgreSQL database
  • Deploy an Nginx server

Artifactory HA architecture

The Artifactory HA cluster in this chart is made up of

  • A single primary node
  • Two member nodes, which can be resized at will

Load balancing is done to the member nodes only. This leaves the primary node free to handle jobs and tasks and not be interrupted by inbound traffic.

This can be controlled by the parameter artifactory.service.pool.

Installing the Chart

To install the chart with the release name artifactory-ha:

bash
$ helm install --name artifactory-ha stable/artifactory-ha

Deploying Artifactory with replicator enabled

bash
## Artifactory replicator is disabled by default. To enable it use the following:
$ helm install --name artifactory --set artifactory.replicator.enabled=true stable/artifactory-ha

Accessing Artifactory

NOTE: It might take a few minutes for Artifactory's public IP to become available, and the nodes to complete initial setup. Follow the instructions outputted by the install command to get the Artifactory IP and URL to access it.

Updating Artifactory

Once you have a new chart version, you can update your deployment with

bash
$ helm upgrade artifactory-ha stable/artifactory-ha

This will apply any configuration changes on your existing deployment.

Artifactory memory and CPU resources

The Artifactory HA Helm chart comes with support for configured resource requests and limits to all pods. By default, these settings are commented out. It is highly recommended to set these so you have full control of the allocated resources and limits.

See more information on setting resources for your Artifactory based on planned usage.

bash
# Example of setting resource requests and limits to all pods (including passing java memory settings to Artifactory)
$ helm install --name artifactory-ha \
               --set artifactory.primary.resources.requests.cpu="500m" \
               --set artifactory.primary.resources.limits.cpu="2" \
               --set artifactory.primary.resources.requests.memory="1Gi" \
               --set artifactory.primary.resources.limits.memory="4Gi" \
               --set artifactory.primary.javaOpts.xms="1g" \
               --set artifactory.primary.javaOpts.xmx="4g" \
               --set artifactory.node.resources.requests.cpu="500m" \
               --set artifactory.node.resources.limits.cpu="2" \
               --set artifactory.node.resources.requests.memory="1Gi" \
               --set artifactory.node.resources.limits.memory="4Gi" \
               --set artifactory.node.javaOpts.xms="1g" \
               --set artifactory.node.javaOpts.xmx="4g" \
               --set postgresql.resources.requests.cpu="200m" \
               --set postgresql.resources.limits.cpu="1" \
               --set postgresql.resources.requests.memory="500Mi" \
               --set postgresql.resources.limits.memory="1Gi" \
               --set nginx.resources.requests.cpu="100m" \
               --set nginx.resources.limits.cpu="250m" \
               --set nginx.resources.requests.memory="250Mi" \
               --set nginx.resources.limits.memory="500Mi" \
               stable/artifactory-ha

Artifactory java memory parameters can (and should) also be set to match the allocated resources with artifactory.[primary|node].javaOpts.xms and artifactory.[primary|node].javaOpts.xmx.

Get more details on configuring Artifactory in the official documentation.

Create Distribution Certificates for Artifactory Enterprise Plus

bash
# Create private.key and root.crt
$ openssl req -newkey rsa:2048 -nodes -keyout private.key -x509 -days 365 -out root.crt

Once Created, Use it to create ConfigMap

bash
# Create ConfigMap distribution-certs
$ kubectl create configmap distribution-certs --from-file=private.key=private.key --from-file=root.crt=root.crt

Pass it to helm

bash
$ helm install --name artifactory --set artifactory.distributionCerts=distribution-certs stable/artifactory-ha

Artifactory storage

Artifactory HA support a wide range of storage back ends. You can see more details on Artifactory HA storage options

In this chart, you set the type of storage you want with artifactory.persistence.type and pass the required configuration settings. The default storage in this chart is the file-system replication, where the data is replicated to all nodes.

IMPORTANT: All storage configurations (except NFS) come with a default artifactory.persistence.redundancy parameter. This is used to set how many replicas of a binary should be stored in the cluster's nodes. Once this value is set on initial deployment, you can not update it using helm. It is recommended to set this to a number greater than half of your cluster's size, and never scale your cluster down to a size smaller than this number.

NFS

To use an NFS server as your cluster's storage, you need to

  • Setup an NFS server. Get its IP as NFS_IP
  • Create a data and backup directories on the NFS exported directory with write permissions to all
  • Pass NFS parameters to helm install and helm upgrade
bash
...
--set artifactory.persistence.type=nfs \
--set artifactory.persistence.nfs.ip=${NFS_IP} \
...

Google Storage

To use a Google Storage bucket as the cluster's filestore

  • Pass Google Storage parameters to helm install and helm upgrade
bash
...
--set artifactory.persistence.type=google-storage \
--set artifactory.persistence.googleStorage.identity=${GCP_ID} \
--set artifactory.persistence.googleStorage.credential=${GCP_KEY} \
...

AWS S3

To use an AWS S3 bucket as the cluster's filestore

  • Pass AWS S3 parameters to helm install and helm upgrade
bash
...
--set artifactory.persistence.type=aws-s3 \
--set artifactory.persistence.awsS3.region=${AWS_REGION} \
--set artifactory.persistence.awsS3.identity=${AWS_ACCESS_KEY_ID} \
--set artifactory.persistence.awsS3.credential=${AWS_SECRET_ACCESS_KEY} \
...

Create a unique Master Key

Artifactory HA cluster requires a unique master key. By default the chart has one set in values.yaml (artifactory.masterKey).

This key is for demo purpose and should not be used in a production environment!

You should generate a unique one and pass it to the template at install/upgrade time.

bash
# Create a key
$ export MASTER_KEY=$(openssl rand -hex 32)
$ echo ${MASTER_KEY}

# Pass the created master key to helm
$ helm install --name artifactory-ha --set artifactory.masterKey=${MASTER_KEY} stable/artifactory-ha

NOTE: Make sure to pass the same master key with --set artifactory.masterKey=${MASTER_KEY} on all future calls to helm install and helm upgrade!

Install Artifactory HA license

For activating Artifactory HA, you must install an appropriate license. There are two ways to manage the license. Artifactory UI or a Kubernetes Secret. The easier and recommended way is the Artifactory UI. Using the Kubernetes Secret is for advanced users and is better suited for automation. IMPORTANT: You should use only one of the following methods. Switching between them while a cluster is running might disable your Artifactory HA cluster!

Artifactory UI

Once primary cluster is running, open Artifactory UI and insert the license(s) in the UI. See HA installation and setup for more details

Kubernetes Secret

You can deploy the Artifactory license(s) as a Kubernetes secret. Prepare a text file with the license(s) written in it. If writing multiple licenses, it's important to put two new lines between each license block!

bash
# Create the Kubernetes secret (assuming the local license file is 'art.lic')
$ kubectl create secret generic artifactory-cluster-license --from-file=./art.lic

# Pass the license to helm
$ helm install --name artifactory-ha --set artifactory.license.secret=artifactory-cluster-license,artifactory.license.dataKey=art.lic stable/artifactory-ha

NOTE: You have to keep passing the license secret parameters as --set artifactory.license.secret=artifactory-cluster-license,artifactory.license.dataKey=art.lic on all future calls to helm install and helm upgrade!

Bootstrapping Artifactory

IMPORTANT: Bootstrapping Artifactory needs license. Pass license as shown in above section.

Create bootstrap-config.yaml with artifactory.config.import.xml and security.import.xml as shown below:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-release-bootstrap-config
data:
  artifactory.config.import.xml: |
    <config contents>
  security.import.xml: |
    <config contents>

Create configMap in Kubernetes:

bash
$ kubectl apply -f bootstrap-config.yaml

Pass the configMap to helm

bash
$ helm install --name artifactory-ha --set artifactory.license.secret=artifactory-cluster-license,artifactory.license.dataKey=art.lic,artifactory.configMapName=my-release-bootstrap-config stable/artifactory-ha

Use custom nginx.conf with Nginx

Steps to create configMap with nginx.conf

  • Create nginx.conf file.
bash
kubectl create configmap nginx-config --from-file=nginx.conf
  • Pass configMap to helm install
bash
helm install --name artifactory-ha --set nginx.customConfigMap=nginx-config stable/artifactory-ha

Scaling your Artifactory cluster

A key feature in Artifactory HA is the ability to set an initial cluster size with --set artifactory.node.replicaCount=${CLUSTER_SIZE} and if needed, resize it.

Before scaling

IMPORTANT: When scaling, you need to explicitly pass the database password if it's an auto generated one (this is the default with the enclosed PostgreSQL helm chart).

Get the current database password

bash
$ export DB_PASSWORD=$(kubectl get $(kubectl get secret -o name | grep postgresql) -o jsonpath="{.data.postgres-password}" | base64 --decode)

Use --set postgresql.postgresPassword=${DB_PASSWORD} with every scale action to prevent a miss configured cluster!

Scale up

Let's assume you have a cluster with 2 member nodes, and you want to scale up to 3 member nodes (a total of 4 nodes).

bash
# Scale to 4 nodes (1 primary and 3 member nodes)
$ helm upgrade --install artifactory-ha --set artifactory.node.replicaCount=3 --set postgresql.postgresPassword=${DB_PASSWORD} stable/artifactory-ha
Scale down

Let's assume you have a cluster with 3 member nodes, and you want to scale down to 2 member node.

bash
# Scale down to 2 member nodes
$ helm upgrade --install artifactory-ha --set artifactory.node.replicaCount=2 --set postgresql.postgresPassword=${DB_PASSWORD} stable/artifactory-ha
  • NOTE: Since Artifactory is running as a Kubernetes Stateful Set, the removal of the node will not remove the persistent volume. You need to explicitly remove it
bash
# List PVCs
$ kubectl get pvc

# Remove the PVC with highest ordinal!
# In this example, the highest node ordinal was 2, so need to remove its storage.
$ kubectl delete pvc volume-artifactory-node-2

Use an external Database

There are cases where you will want to use a different database and not the enclosed PostgreSQL. See more details on configuring the database

The official Artifactory Docker images include the PostgreSQL database driver. For other database types, you will have to add the relevant database driver to Artifactory's tomcat/lib

This can be done with the following parameters

bash
# Make sure your Artifactory Docker image has the MySQL database driver in it
...
--set postgresql.enabled=false \
--set artifactory.postStartCommand="curl -L -o /opt/jfrog/artifactory/tomcat/lib/mysql-connector-java-5.1.41.jar https://jcenter.bintray.com/mysql/mysql-connector-java/5.1.41/mysql-connector-java-5.1.41.jar && chown 1030:1030 /opt/jfrog/artifactory/tomcat/lib/mysql-connector-java-5.1.41.jar" \
--set database.type=mysql \
--set database.host=${DB_HOST} \
--set database.port=${DB_PORT} \
--set database.user=${DB_USER} \
--set database.password=${DB_PASSWORD} \
...

NOTE: You must set postgresql.enabled=false in order for the chart to use the database.* parameters. Without it, they will be ignored!

Deleting Artifactory

To delete the Artifactory HA cluster

bash
$ helm delete --purge artifactory-ha

This will completely delete your Artifactory HA cluster.
NOTE: Since Artifactory is running as Kubernetes Stateful Sets, the removal of the helm release will not remove the persistent volumes. You need to explicitly remove them

bash
$ kubectl delete pvc -l release=artifactory-ha

See more details in the official Kubernetes Stateful Set removal page

Custom Docker registry for your images

If you need to pull your Docker images from a private registry (for example, when you have a custom image with a MySQL database driver), you need to create a Kubernetes Docker registry secret and pass it to helm

bash
# Create a Docker registry secret called 'regsecret'
$ kubectl create secret docker-registry regsecret --docker-server=${DOCKER_REGISTRY} --docker-username=${DOCKER_USER} --docker-password=${DOCKER_PASS} --docker-email=${DOCKER_EMAIL}

Once created, you pass it to helm

bash
$ helm install --name artifactory-ha --set imagePullSecrets=regsecret stable/artifactory-ha

Configuration

The following table lists the configurable parameters of the artifactory chart and their default values.

ParameterDescriptionDefault
imagePullSecretsDocker registry pull secret
serviceAccount.createSpecifies whether a ServiceAccount should be createdtrue
serviceAccount.nameThe name of the ServiceAccount to createGenerated using the fullname template
rbac.createSpecifies whether RBAC resources should be createdtrue
rbac.role.rulesRules to create[]
artifactory.nameArtifactory nameartifactory
artifactory.image.pullPolicyContainer pull policyIfNotPresent
artifactory.image.repositoryContainer imagedocker.bintray.io/jfrog/artifactory-pro
artifactory.image.versionContainer image tag6.2.0
artifactory.masterKeyArtifactory Master Key. Can be generated with openssl rand -hex 32FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
artifactory.license.secretArtifactory license secret name
artifactory.license.dataKeyArtifactory license secret data key
artifactory.service.nameArtifactory service name to be set in Nginx configurationartifactory
artifactory.service.typeArtifactory service typeClusterIP
artifactory.service.poolArtifactory instances to be in the load balancing pool. members or allmembers
artifactory.externalPortArtifactory service external port8081
artifactory.internalPortArtifactory service internal port8081
artifactory.internalPortReplicatorReplicator service internal port6061
artifactory.externalPortReplicatorReplicator service external port6061
artifactory.livenessProbe.enabledEnable liveness probetrue
artifactory.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated180
artifactory.livenessProbe.periodSecondsHow often to perform the probe10
artifactory.livenessProbe.timeoutSecondsWhen the probe times out10
artifactory.livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
artifactory.livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.10
artifactory.readinessProbe.enabledwould you like a readinessProbe to be enabledtrue
artifactory.readinessProbe.initialDelaySecondsDelay before readiness probe is initiated60
artifactory.readinessProbe.periodSecondsHow often to perform the probe10
artifactory.readinessProbe.timeoutSecondsWhen the probe times out10
artifactory.readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
artifactory.readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.10
artifactory.persistence.mountPathArtifactory persistence volume mount path"/var/opt/jfrog/artifactory"
artifactory.persistence.enabledArtifactory persistence volume enabledtrue
artifactory.persistence.accessModeArtifactory persistence volume access modeReadWriteOnce
artifactory.persistence.sizeArtifactory persistence volume size200Gi
artifactory.persistence.typeArtifactory HA storage typefile-system
artifactory.persistence.redundancyArtifactory HA storage redundancy3
artifactory.persistence.nfs.ipNFS server IP
artifactory.persistence.nfs.haDataMountNFS data directory/data
artifactory.persistence.nfs.haBackupMountNFS backup directory/backup
artifactory.persistence.nfs.dataDirHA data directory/var/opt/jfrog/artifactory-ha
artifactory.persistence.nfs.backupDirHA backup directory/var/opt/jfrog/artifactory-backup
artifactory.persistence.nfs.capacityNFS PVC size200Gi
artifactory.persistence.googleStorage.bucketNameGoogle Storage bucket nameartifactory-ha
artifactory.persistence.googleStorage.identityGoogle Storage service account id
artifactory.persistence.googleStorage.credentialGoogle Storage service account key
artifactory.persistence.googleStorage.pathGoogle Storage path in bucketartifactory-ha/filestore
artifactory.persistence.awsS3.bucketNameAWS S3 bucket nameartifactory-ha
artifactory.persistence.awsS3.regionAWS S3 bucket region
artifactory.persistence.awsS3.identityAWS S3 AWS_ACCESS_KEY_ID
artifactory.persistence.awsS3.credentialAWS S3 AWS_SECRET_ACCESS_KEY
artifactory.persistence.awsS3.pathAWS S3 path in bucketartifactory-ha/filestore
artifactory.javaOpts.otherArtifactory extra java options (for all nodes)-Dartifactory.locking.provider.type=db
artifactory.replicator.enabledEnable Artifactory Replicatorfalse
artifactory.distributionCertsName of ConfigMap for Artifactory Distribution Certificate
artifactory.replicator.publicUrlArtifactory Replicator Public URL
artifactory.primary.resources.requests.memoryArtifactory primary node initial memory request
artifactory.primary.resources.requests.cpuArtifactory primary node initial cpu request
artifactory.primary.resources.limits.memoryArtifactory primary node memory limit
artifactory.primary.resources.limits.cpuArtifactory primary node cpu limit
artifactory.primary.javaOpts.xmsArtifactory primary node java Xms size
artifactory.primary.javaOpts.xmxArtifactory primary node java Xms size
artifactory.primary.javaOpts.otherArtifactory primary node additional java options
artifactory.node.replicaCountArtifactory member node replica count1
artifactory.node.resources.requests.memoryArtifactory member node initial memory request
artifactory.node.resources.requests.cpuArtifactory member node initial cpu request
artifactory.node.resources.limits.memoryArtifactory member node memory limit
artifactory.node.resources.limits.cpuArtifactory member node cpu limit
artifactory.node.javaOpts.xmsArtifactory member node java Xms size
artifactory.node.javaOpts.xmxArtifactory member node java Xms size
artifactory.node.javaOpts.otherArtifactory member node additional java options
ingress.enabledIf true, Artifactory Ingress will be createdfalse
ingress.annotationsArtifactory Ingress annotations{}
ingress.hostsArtifactory Ingress hostnames[]
ingress.tlsArtifactory Ingress TLS configuration (YAML)[]
nginx.enabledDeploy nginx servertrue
nginx.nameNginx namenginx
nginx.replicaCountNginx replica count1
nginx.image.repositoryContainer imagedocker.bintray.io/jfrog/nginx-artifactory-pro
nginx.image.versionContainer version6.2.0
nginx.image.pullPolicyContainer pull policyIfNotPresent
nginx.service.typeNginx service typeLoadBalancer
nginx.service.loadBalancerSourceRangesNginx service array of IP CIDR ranges to whitelist (only when service type is LoadBalancer)
nginx.loadBalancerIPProvide Static IP to configure with Nginx
nginx.externalPortHttpNginx service external port80
nginx.internalPortHttpNginx service internal port80
nginx.externalPortHttpsNginx service external port443
nginx.internalPortHttpsNginx service internal port443
nginx.internalPortReplicatorReplicator service internal port6061
nginx.externalPortReplicatorReplicator service external port6061
nginx.livenessProbe.enabledwould you like a liveness Probe to be enabledtrue
nginx.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated100
nginx.livenessProbe.periodSecondsHow often to perform the probe10
nginx.livenessProbe.timeoutSecondsWhen the probe times out10
nginx.livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
nginx.livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.10
nginx.readinessProbe.enabledwould you like a readinessProbe to be enabledtrue
nginx.readinessProbe.initialDelaySecondsDelay before readiness probe is initiated60
nginx.readinessProbe.periodSecondsHow often to perform the probe10
nginx.readinessProbe.timeoutSecondsWhen the probe times out10
nginx.readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
nginx.readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.10
nginx.tlsSecretNameSSL secret that will be used by the Nginx pod
nginx.env.sslNginx Environment enable ssltrue
nginx.env.skipAutoConfigUpdateNginx Environment to disable auto configuration updatefalse
nginx.customConfigMapNginx CustomeConfigMap name for nginx.conf
nginx.resources.requests.memoryNginx initial memory request250Mi
nginx.resources.requests.cpuNginx initial cpu request100m
nginx.resources.limits.memoryNginx memory limit250Mi
nginx.resources.limits.cpuNginx cpu limit500m
postgresql.enabledUse enclosed PostgreSQL as databasetrue
postgresql.postgresDatabasePostgreSQL database nameartifactory
postgresql.postgresUserPostgreSQL database userartifactory
postgresql.postgresPasswordPostgreSQL database password
postgresql.persistence.enabledPostgreSQL use persistent storagetrue
postgresql.persistence.sizePostgreSQL persistent storage size50Gi
postgresql.service.portPostgreSQL database port5432
postgresql.resources.requests.memoryPostgreSQL initial memory request
postgresql.resources.requests.cpuPostgreSQL initial cpu request
postgresql.resources.limits.memoryPostgreSQL memory limit
postgresql.resources.limits.cpuPostgreSQL cpu limit
database.typeExternal database type (postgresql, mysql, oracle or mssql)
database.hostExternal database hostname
database.portExternal database port
database.userExternal database username
database.passwordExternal database password

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

Ingress and TLS

To get Helm to create an ingress object with a hostname, add these two lines to your Helm command:

helm install --name artifactory-ha \
  --set ingress.enabled=true \
  --set ingress.hosts[0]="artifactory.company.com" \
  --set artifactory.service.type=NodePort \
  --set nginx.enabled=false \
  stable/artifactory-ha

If your cluster allows automatic creation/retrieval of TLS certificates (e.g. cert-manager), please refer to the documentation for that mechanism.

To manually configure TLS, first create/retrieve a key & certificate pair for the address(es) you wish to protect. Then create a TLS secret in the namespace:

console
kubectl create secret tls artifactory-tls --cert=path/to/tls.cert --key=path/to/tls.key

Include the secret's name, along with the desired hostnames, in the Artifactory Ingress TLS section of your custom values.yaml file:

  ingress:
    ## If true, Artifactory Ingress will be created
    ##
    enabled: true

    ## Artifactory Ingress hostnames
    ## Must be provided if Ingress is enabled
    ##
    hosts:
      - artifactory.domain.com
    annotations:
      kubernetes.io/tls-acme: "true"
    ## Artifactory Ingress TLS configuration
    ## Secrets must be manually created in the namespace
    ##
    tls:
      - secretName: artifactory-tls
        hosts:
          - artifactory.domain.com