|
| 1 | +# JIT Container Registry Credentials Manager |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This Helm chart deploys a system to manage and rotate Jit container registry secrets automatically. It ensures that containers (which are controls) can be pulled from the Jit Container Registry by maintaining up-to-date credentials. |
| 6 | + |
| 7 | +## Purpose |
| 8 | + |
| 9 | +The main purpose of this chart is to: |
| 10 | + |
| 11 | +1. Authenticate with the Jit API to obtain container registry credentials. |
| 12 | +2. Create and update a Kubernetes secret containing these credentials. |
| 13 | +3. Periodically refresh the credentials to ensure continued access to the Jit Container Registry. |
| 14 | + |
| 15 | +## Components |
| 16 | + |
| 17 | +The chart consists of the following main components: |
| 18 | + |
| 19 | +1. **Initial Login Job**: A one-time job that runs immediately after chart installation to set up the initial container registry credentials. |
| 20 | +2. **Refresh CronJob**: A periodically running job that refreshes the container registry credentials to ensure they remain valid. |
| 21 | +3. **ConfigMap**: Contains the script used by both the initial job and the CronJob to fetch and update the credentials. |
| 22 | +4. **ServiceAccount and RBAC**: Provides necessary permissions for the jobs to create and update secrets in the specified namespace. |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +- Kubernetes 1.16+ |
| 27 | +- Helm 3.0+ |
| 28 | +- A valid Jit account with API credentials (Client ID and Secret) |
| 29 | + - These can be obtained from https://docs.jit.io/docs/managing-users#generating-api-tokens |
| 30 | + - The API credentials should be created with the Member role |
| 31 | + - The secret should be kept securely and not shared or exposed publicly |
| 32 | + |
| 33 | +## Installation |
| 34 | + |
| 35 | +To install the chart with the release name `jit-registry`: |
| 36 | + |
| 37 | +```bash |
| 38 | +helm install jit-registry . \ |
| 39 | + --set client_id=your-client-id \ |
| 40 | + --set secret=your-secret \ |
| 41 | + --set namespace=your-namespace |
| 42 | +``` |
| 43 | + |
| 44 | +## Configuration |
| 45 | + |
| 46 | +The following table lists the configurable parameters of the JIT Container Registry Credentials Manager chart and their default values. |
| 47 | + |
| 48 | +| Parameter | Description | Default | |
| 49 | +|-----------|-------------|---------| |
| 50 | +| `client_id` | Jit API Client ID (Member role) | `"<JIT_API_CLIENT_ID>"` | |
| 51 | +| `secret` | Jit API Secret | `"<JIT_API_SECRET>"` | |
| 52 | +| `jit_base_url` | Jit API Base URL | `"https://api.jit.io"` | |
| 53 | +| `registry_name` | Jit Container Registry Name | `"registry.jit.io"` | |
| 54 | +| `keep_job_history_seconds` | Time (in seconds) to keep job history | `86400` | |
| 55 | +| `namespace` | Kubernetes namespace to deploy to | `"default"` | |
| 56 | +| `jit_ecr_secret_name` | Name of the Kubernetes secret for container registry credentials | `"jit-registry-creds"` | |
| 57 | + |
| 58 | +To modify any of these parameters, you can use the `--set key=value[,key=value]` argument to `helm install` or `helm upgrade`, or modify the `values.yaml` file directly. |
| 59 | + |
| 60 | +Note: The `client_id` and `secret` should be obtained from https://docs.jit.io/docs/managing-users#generating-api-tokens. Make sure to use the "Member" role when generating these credentials. Please store these values in a secure place and never expose them publicly. |
| 61 | + |
| 62 | +The `jit_ecr_secret_name` should match the Kubernetes runner configuration. For example, in GitLab: |
| 63 | + |
| 64 | +```yaml |
| 65 | +[runners.kubernetes] |
| 66 | + poll_timeout = 2000 |
| 67 | + node_selector_overwrite_allowed = ".*" |
| 68 | + image_pull_secrets=["jit-registry-creds"] |
| 69 | +``` |
| 70 | + |
| 71 | +## Usage |
| 72 | + |
| 73 | +After installation, the chart will: |
| 74 | + |
| 75 | +1. Create an initial Kubernetes secret with container registry credentials. |
| 76 | +2. Set up a CronJob to refresh these credentials periodically. |
| 77 | + |
| 78 | +You can use the created secret (`jit-registry-creds` by default) in your pod specifications to pull images from the Jit Container Registry: |
| 79 | + |
| 80 | +```yaml |
| 81 | +spec: |
| 82 | + imagePullSecrets: |
| 83 | + - name: jit-registry-creds |
| 84 | + containers: |
| 85 | + - name: your-container |
| 86 | + image: registry.jit.io/your-image:tag |
| 87 | +``` |
| 88 | +
|
| 89 | +## Monitoring and Troubleshooting |
| 90 | +
|
| 91 | +To check the status of the initial login job: |
| 92 | +
|
| 93 | +```bash |
| 94 | +kubectl get jobs -n your-namespace jit-registry-initial-login |
| 95 | +``` |
| 96 | + |
| 97 | +To check the status of the refresh CronJob: |
| 98 | + |
| 99 | +```bash |
| 100 | +kubectl get cronjobs -n your-namespace jit-registry-refresh |
| 101 | +``` |
| 102 | + |
| 103 | +To view logs of the most recent job execution: |
| 104 | + |
| 105 | +```bash |
| 106 | +kubectl logs -n your-namespace job/jit-registry-refresh-<job-id> |
| 107 | +``` |
| 108 | + |
| 109 | +For more detailed instructions, please refer to the NOTES.txt file that is displayed after chart installation. |
| 110 | + |
| 111 | +## Uninstalling the Chart |
| 112 | + |
| 113 | +To uninstall/delete the `jit-registry` deployment: |
| 114 | + |
| 115 | +```bash |
| 116 | +helm delete jit-registry |
| 117 | +``` |
| 118 | + |
| 119 | +This command removes all the Kubernetes components associated with the chart and deletes the release. |
| 120 | + |
| 121 | +## Security Considerations |
| 122 | + |
| 123 | +- The Jit API Secret is sensitive information. Always handle it securely and avoid exposing it in logs, command-line arguments, or version control systems. |
| 124 | +- Use Kubernetes Secrets or a secure secrets management system to store the `client_id` and `secret`. |
| 125 | +- Regularly rotate your Jit API credentials as per your organization's security policies. |
| 126 | + |
| 127 | +## Support |
| 128 | + |
| 129 | +For any issues or questions, please contact Jit support or open an issue in the chart's repository. |
0 commit comments