|
| 1 | +# ci-cassandra Cluster Management |
| 2 | +<!-- |
| 3 | +Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +or more contributor license agreements. See the NOTICE file |
| 5 | +distributed with this work for additional information |
| 6 | +regarding copyright ownership. The ASF licenses this file |
| 7 | +to you under the Apache License, Version 2.0 (the |
| 8 | +"License"); you may not use this file except in compliance |
| 9 | +with the License. You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +This directory manages the Helm-based deployment of **ci-cassandra.infra.datastax.com**, |
| 21 | +the pre-commit Jenkins CI cluster for Apache Cassandra running on GKE in the |
| 22 | +`cassandra-oss` GCP project. |
| 23 | + |
| 24 | +It extends the upstream `../jenkins-deployment.yaml` with: |
| 25 | +- **Let's Encrypt TLS** via cert-manager and an nginx sidecar |
| 26 | +- **Helmfile** so that cert-manager, the issuer, and Jenkins are all managed |
| 27 | + together in dependency order |
| 28 | + |
| 29 | +## Directory layout |
| 30 | + |
| 31 | +``` |
| 32 | +ci-cassandra/ |
| 33 | +├── helmfile.yaml # orchestrates all three releases in order |
| 34 | +├── cert-manager-values.yaml # jetstack/cert-manager Helm values |
| 35 | +├── cert-issuer-values.yaml # hostname, email, secret name |
| 36 | +├── jenkins-tls-overrides.yaml # nginx sidecar + port 443 + nodeSelector fix |
| 37 | +├── nginx-configmap.yaml # nginx config (applied by deploy.sh, not Helm) |
| 38 | +├── deploy.sh # install / upgrade script |
| 39 | +├── charts/ |
| 40 | +│ └── cert-issuer/ # minimal local chart: ClusterIssuer + Certificate |
| 41 | +└── README.md # this file |
| 42 | +``` |
| 43 | + |
| 44 | +## Prerequisites |
| 45 | + |
| 46 | +```bash |
| 47 | +brew install helm helmfile |
| 48 | +helm plugin install https://github.com/databus23/helm-diff # helm 3 |
| 49 | +# helm 4: helm plugin install --verify=false https://github.com/databus23/helm-diff |
| 50 | + |
| 51 | +gcloud auth login |
| 52 | +gcloud auth application-default login |
| 53 | +gcloud container clusters get-credentials mck-cassandra-jenkins-hamina-2 \ |
| 54 | + --zone europe-north1-a --project cassandra-oss |
| 55 | +``` |
| 56 | + |
| 57 | +## How TLS works |
| 58 | + |
| 59 | +``` |
| 60 | +Browser → NLB:443 (TCP passthrough, 34.88.16.212) |
| 61 | + → Jenkins pod:4443 (nginx sidecar — TLS termination) |
| 62 | + → localhost:8080 (Jenkins) |
| 63 | +
|
| 64 | +Let's Encrypt renewal: |
| 65 | +LE server → NLB:80 → Jenkins pod:8080 → ACME solver pod |
| 66 | +``` |
| 67 | + |
| 68 | +The NLB on port 80 stays open. cert-manager spins up a temporary pod to |
| 69 | +answer the HTTP-01 challenge; the traffic reaches it through the existing |
| 70 | +port-80 path. After the challenge succeeds, cert-manager writes the |
| 71 | +certificate into the `cassius-jenkins-tls` Secret. The nginx sidecar mounts |
| 72 | +that Secret and serves HTTPS. |
| 73 | + |
| 74 | +Certificates renew automatically ~30 days before expiry. No manual |
| 75 | +intervention is required after the initial deploy. |
| 76 | + |
| 77 | +## First-time install |
| 78 | + |
| 79 | +```bash |
| 80 | +cd .jenkins/k8s/ci-cassandra |
| 81 | +./deploy.sh |
| 82 | +``` |
| 83 | + |
| 84 | +The script: |
| 85 | +1. Checks prerequisites (helm, helmfile, helm-diff, kubectl, gcloud) |
| 86 | +2. Adds and updates Helm repos |
| 87 | +3. Applies the nginx ConfigMap |
| 88 | +4. Runs `helmfile apply`, which installs in order: |
| 89 | + - `cert-manager` (in the `cert-manager` namespace) |
| 90 | + - `cert-issuer` (ClusterIssuer + Certificate in `default`) |
| 91 | + - `cassius` (Jenkins in `default`) |
| 92 | + |
| 93 | +Certificate issuance takes 1–3 minutes after deploy completes. Watch it: |
| 94 | +```bash |
| 95 | +kubectl get certificate cassius-jenkins-tls -n default -w |
| 96 | +``` |
| 97 | + |
| 98 | +## Upgrading Jenkins |
| 99 | + |
| 100 | +```bash |
| 101 | +./deploy.sh --jenkins-only |
| 102 | +``` |
| 103 | + |
| 104 | +Upgrades only the `cassius` release (skips cert-manager and cert-issuer). |
| 105 | + |
| 106 | +## Dry run |
| 107 | + |
| 108 | +```bash |
| 109 | +./deploy.sh --dry-run |
| 110 | +``` |
| 111 | + |
| 112 | +Shows what would change without applying anything. |
| 113 | + |
| 114 | +## Checking certificate status |
| 115 | + |
| 116 | +```bash |
| 117 | +kubectl describe certificate cassius-jenkins-tls -n default |
| 118 | +kubectl get certificaterequest -n default |
| 119 | +kubectl get challenges -n default # only present during issuance |
| 120 | +``` |
| 121 | + |
| 122 | +## Rolling back a bad upgrade |
| 123 | + |
| 124 | +```bash |
| 125 | +helm history cassius -n default |
| 126 | +helm rollback cassius <last-good-revision> -n default --wait --timeout 15m |
| 127 | +``` |
| 128 | + |
| 129 | +## Customising for a different site |
| 130 | + |
| 131 | +Copy `cert-issuer-values.yaml` and `jenkins-tls-overrides.yaml` and adjust: |
| 132 | +- `acmeEmail` and `hostname` in cert-issuer-values.yaml |
| 133 | +- `storageClass` in jenkins-tls-overrides.yaml (e.g. `gp2` for AWS) |
| 134 | +- Any site-specific annotations (static IP, internal LB, etc.) |
| 135 | + |
| 136 | +Pass your copy as additional `-f` arguments to `helmfile apply` or add it to |
| 137 | +the `values:` list in `helmfile.yaml`. |
| 138 | + |
| 139 | +## Node pools |
| 140 | + |
| 141 | +The GKE cluster requires these node pools (created once; see `../README.md`): |
| 142 | + |
| 143 | +| Pool | Label | Machine type | Max nodes | |
| 144 | +|------|-------|--------------|-----------| |
| 145 | +| default-pool | `cassandra.jenkins.controller=true` | e2-standard-8 | 1 | |
| 146 | +| agents-small | `cassandra.jenkins.agent.small=true` | e2-highcpu-8 | 20 | |
| 147 | +| agents-report | `cassandra.jenkins.agent.report=true` | n2-standard-8 | 4 | |
| 148 | +| agents-medium | `cassandra.jenkins.agent.medium=true` | n2-highcpu-8 | 150 | |
| 149 | +| agents-large | `cassandra.jenkins.agent.large=true` | n2-standard-8 | 306 | |
| 150 | + |
| 151 | +The `agents-report` pool is required for the `generateTestReports` pipeline |
| 152 | +stage. Without it, that stage will wait indefinitely. |
| 153 | + |
| 154 | +For the current `ci-cassandra.infra.datastax.com` cluster, the `agents-report` |
| 155 | +pool does not yet exist and can be created with: |
| 156 | + |
| 157 | +```bash |
| 158 | +gcloud container node-pools create agents-report \ |
| 159 | + --cluster mck-cassandra-jenkins-hamina-2 \ |
| 160 | + --zone europe-north1-a \ |
| 161 | + --project cassandra-oss \ |
| 162 | + --machine-type n2-standard-8 \ |
| 163 | + --disk-type=pd-ssd \ |
| 164 | + --disk-size=107 \ |
| 165 | + --enable-autoscaling \ |
| 166 | + --spot \ |
| 167 | + --num-nodes=0 \ |
| 168 | + --min-nodes=0 \ |
| 169 | + --max-nodes=4 \ |
| 170 | + --node-labels=cassandra.jenkins.agent=true,cassandra.jenkins.agent.report=true |
| 171 | +``` |
0 commit comments