rdeploy 0.4.2__tar.gz → 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdeploy
3
- Version: 0.4.2
3
+ Version: 0.5.1
4
4
  Summary: CLI that makes it easy to build and deploy an application to k8s.
5
5
  Author-email: Rehive <info@rehive.com>
6
6
  License: MIT
@@ -71,6 +71,7 @@ rdeploy git-release patch
71
71
  | `set-project` | Set the active GCP project |
72
72
  | `set-cluster` | Set the active Kubernetes cluster |
73
73
  | `set-context` | Switch cluster and namespace context |
74
+ | `kubectl-login` | Sign kubectl in to GKE under certificate-based access (see [kubectl under certificate-based access](#kubectl-under-certificate-based-access)) |
74
75
  | `activate` | Fetch and set project, cluster, and namespace |
75
76
  | `install` | Install a Helm chart deployment |
76
77
  | `upgrade` | Upgrade a Helm deployment to a new image tag (atomic by default: waits for the rollout and rolls back on failure; use `--no-atomic` to skip, `--timeout` to adjust the wait, default `15m`) |
@@ -93,6 +94,107 @@ rdeploy git-release patch
93
94
  | `create-volume` | Create a GCE persistent disk |
94
95
  | `compose` | Wrapper for docker-compose |
95
96
 
97
+ ## kubectl under certificate-based access
98
+
99
+ With Google Cloud certificate-based access (CBA), gcloud's tokens only work
100
+ alongside your device certificate, and kubectl can't present it.
101
+ `rdeploy kubectl-login` signs kubectl in through a separate OAuth client that
102
+ your organisation exempts from CBA instead. It asks only for
103
+ `openid email https://www.googleapis.com/auth/container.read-only`: enough to
104
+ identify you to the clusters, where Kubernetes RBAC decides what you can do,
105
+ and nothing else in Google Cloud.
106
+
107
+ The exemption is narrow and doesn't stand alone. Access to the clusters stays
108
+ layered:
109
+
110
+ - **Network isolation:** the control plane should have only a private
111
+ endpoint, reachable from your private network through a bastion or similar
112
+ access gateway, and limited to authorised networks. A token alone doesn't
113
+ reach the cluster.
114
+ - **Least privilege:** the token can identify you and read GKE metadata, but
115
+ can't call any other Google Cloud API or change clusters through the GKE API.
116
+ - **Device trust:** the OAuth client is fetched from Secret Manager with your
117
+ gcloud login, which still needs your device certificate.
118
+ - **Short sessions:** your organisation sets how long a sign-in lasts (often
119
+ 12 hours), so a copied credentials file stops working soon after.
120
+ - **Kubernetes RBAC and audit logs:** what you can do inside a cluster, and
121
+ the record of what you did, are unchanged.
122
+
123
+ It:
124
+
125
+ 1. reads the OAuth client from Secret Manager with your gcloud login (or from
126
+ a local file with `--client-json`),
127
+ 2. opens your browser to sign in (OAuth loopback with PKCE),
128
+ 3. saves the credentials to `~/.config/rdeploy/kubectl-credentials.json`,
129
+ readable only by you,
130
+ 4. finds the project's GKE clusters (`gcloud container clusters list`), adds
131
+ any that are missing from your kubeconfig, and points their contexts at a
132
+ kubectl user that uses those credentials.
133
+
134
+ ### One-time setup
135
+
136
+ You need gcloud signed in with your work account and set up for your device
137
+ certificate, kubectl, and the GKE auth plugin
138
+ (`gcloud components install gke-gcloud-auth-plugin`). Then run this from any
139
+ project that has an `rdeploy.yaml`:
140
+
141
+ ```bash
142
+ rdeploy kubectl-login
143
+ ```
144
+
145
+ rdeploy takes the GCP project from that `rdeploy.yaml` and reads the OAuth
146
+ client from the Secret Manager secret `kubectl-oauth-client` in it. If your
147
+ `rdeploy.yaml` names several projects, you're elsewhere, or your organisation
148
+ uses another secret name, say so:
149
+
150
+ ```bash
151
+ rdeploy kubectl-login --gcp-project my-project --secret my-secret
152
+ ```
153
+
154
+ rdeploy saves the project and secret to `~/.config/rdeploy/kubectl-login.json`,
155
+ so later runs work from any directory. You can set `RDEPLOY_KUBECTL_PROJECT`
156
+ and `RDEPLOY_KUBECTL_SECRET` instead. Pass `--account you@example.com` if
157
+ gcloud's active account isn't the one to sign in with, and `--cluster NAME`
158
+ (repeatable) to configure only some clusters.
159
+
160
+ ### When the session expires
161
+
162
+ Sessions last as long as your organisation allows, often 12 hours. When
163
+ kubectl fails with an authentication error such as `invalid_grant` or
164
+ `reauth related error`, sign in again:
165
+
166
+ ```bash
167
+ rdeploy kubectl-login
168
+ ```
169
+
170
+ To check whether the saved session is still valid (exits non-zero if not):
171
+
172
+ ```bash
173
+ rdeploy kubectl-login --status
174
+ ```
175
+
176
+ ### Troubleshooting
177
+
178
+ - **`Unauthorized` right after signing in:** delete
179
+ `~/.kube/gke_gcloud_auth_plugin_cache` and retry.
180
+ - **`access_not_configured` or "Access blocked" in the browser:** the OAuth
181
+ client only allows the scopes above, so use `rdeploy kubectl-login` rather
182
+ than `gcloud auth application-default login`, which always asks for more.
183
+ If it still fails, your admin hasn't allowed the app for your account.
184
+ - **Back to the gcloud user:** `gcloud container clusters get-credentials`
185
+ restores the default user on that cluster's context.
186
+
187
+ ### For admins
188
+
189
+ The command expects a Desktop app OAuth client, exempted from CBA in your
190
+ access levels, limited to the scopes above, and stored as JSON (the file the
191
+ Cloud console downloads) in a Secret Manager secret your developers can read,
192
+ named `kubectl-oauth-client` in the project your `rdeploy.yaml` files name
193
+ unless you tell developers otherwise. Keep the session length short in the
194
+ app's session control, keep the control plane on a private endpoint behind
195
+ your access gateway, and leave CBA enforced for everything else.
196
+ rdeploy doesn't contain any organisation's client ID, project or cluster names.
197
+
96
198
  ## Configuration
97
199
 
98
200
  rdeploy is configured via an `rdeploy.yaml` file in your project root. The file supports versioned schemas (v1, v2, v3).
@@ -222,7 +324,7 @@ coverage report
222
324
  ## Requirements
223
325
 
224
326
  - Python 3.9+
225
- - kubectl configured with cluster access
327
+ - kubectl configured with cluster access (1.22 or later for `kubectl-login`)
226
328
  - gcloud CLI configured and authenticated
227
329
  - Helm 3.x
228
330
 
@@ -34,6 +34,7 @@ rdeploy git-release patch
34
34
  | `set-project` | Set the active GCP project |
35
35
  | `set-cluster` | Set the active Kubernetes cluster |
36
36
  | `set-context` | Switch cluster and namespace context |
37
+ | `kubectl-login` | Sign kubectl in to GKE under certificate-based access (see [kubectl under certificate-based access](#kubectl-under-certificate-based-access)) |
37
38
  | `activate` | Fetch and set project, cluster, and namespace |
38
39
  | `install` | Install a Helm chart deployment |
39
40
  | `upgrade` | Upgrade a Helm deployment to a new image tag (atomic by default: waits for the rollout and rolls back on failure; use `--no-atomic` to skip, `--timeout` to adjust the wait, default `15m`) |
@@ -56,6 +57,107 @@ rdeploy git-release patch
56
57
  | `create-volume` | Create a GCE persistent disk |
57
58
  | `compose` | Wrapper for docker-compose |
58
59
 
60
+ ## kubectl under certificate-based access
61
+
62
+ With Google Cloud certificate-based access (CBA), gcloud's tokens only work
63
+ alongside your device certificate, and kubectl can't present it.
64
+ `rdeploy kubectl-login` signs kubectl in through a separate OAuth client that
65
+ your organisation exempts from CBA instead. It asks only for
66
+ `openid email https://www.googleapis.com/auth/container.read-only`: enough to
67
+ identify you to the clusters, where Kubernetes RBAC decides what you can do,
68
+ and nothing else in Google Cloud.
69
+
70
+ The exemption is narrow and doesn't stand alone. Access to the clusters stays
71
+ layered:
72
+
73
+ - **Network isolation:** the control plane should have only a private
74
+ endpoint, reachable from your private network through a bastion or similar
75
+ access gateway, and limited to authorised networks. A token alone doesn't
76
+ reach the cluster.
77
+ - **Least privilege:** the token can identify you and read GKE metadata, but
78
+ can't call any other Google Cloud API or change clusters through the GKE API.
79
+ - **Device trust:** the OAuth client is fetched from Secret Manager with your
80
+ gcloud login, which still needs your device certificate.
81
+ - **Short sessions:** your organisation sets how long a sign-in lasts (often
82
+ 12 hours), so a copied credentials file stops working soon after.
83
+ - **Kubernetes RBAC and audit logs:** what you can do inside a cluster, and
84
+ the record of what you did, are unchanged.
85
+
86
+ It:
87
+
88
+ 1. reads the OAuth client from Secret Manager with your gcloud login (or from
89
+ a local file with `--client-json`),
90
+ 2. opens your browser to sign in (OAuth loopback with PKCE),
91
+ 3. saves the credentials to `~/.config/rdeploy/kubectl-credentials.json`,
92
+ readable only by you,
93
+ 4. finds the project's GKE clusters (`gcloud container clusters list`), adds
94
+ any that are missing from your kubeconfig, and points their contexts at a
95
+ kubectl user that uses those credentials.
96
+
97
+ ### One-time setup
98
+
99
+ You need gcloud signed in with your work account and set up for your device
100
+ certificate, kubectl, and the GKE auth plugin
101
+ (`gcloud components install gke-gcloud-auth-plugin`). Then run this from any
102
+ project that has an `rdeploy.yaml`:
103
+
104
+ ```bash
105
+ rdeploy kubectl-login
106
+ ```
107
+
108
+ rdeploy takes the GCP project from that `rdeploy.yaml` and reads the OAuth
109
+ client from the Secret Manager secret `kubectl-oauth-client` in it. If your
110
+ `rdeploy.yaml` names several projects, you're elsewhere, or your organisation
111
+ uses another secret name, say so:
112
+
113
+ ```bash
114
+ rdeploy kubectl-login --gcp-project my-project --secret my-secret
115
+ ```
116
+
117
+ rdeploy saves the project and secret to `~/.config/rdeploy/kubectl-login.json`,
118
+ so later runs work from any directory. You can set `RDEPLOY_KUBECTL_PROJECT`
119
+ and `RDEPLOY_KUBECTL_SECRET` instead. Pass `--account you@example.com` if
120
+ gcloud's active account isn't the one to sign in with, and `--cluster NAME`
121
+ (repeatable) to configure only some clusters.
122
+
123
+ ### When the session expires
124
+
125
+ Sessions last as long as your organisation allows, often 12 hours. When
126
+ kubectl fails with an authentication error such as `invalid_grant` or
127
+ `reauth related error`, sign in again:
128
+
129
+ ```bash
130
+ rdeploy kubectl-login
131
+ ```
132
+
133
+ To check whether the saved session is still valid (exits non-zero if not):
134
+
135
+ ```bash
136
+ rdeploy kubectl-login --status
137
+ ```
138
+
139
+ ### Troubleshooting
140
+
141
+ - **`Unauthorized` right after signing in:** delete
142
+ `~/.kube/gke_gcloud_auth_plugin_cache` and retry.
143
+ - **`access_not_configured` or "Access blocked" in the browser:** the OAuth
144
+ client only allows the scopes above, so use `rdeploy kubectl-login` rather
145
+ than `gcloud auth application-default login`, which always asks for more.
146
+ If it still fails, your admin hasn't allowed the app for your account.
147
+ - **Back to the gcloud user:** `gcloud container clusters get-credentials`
148
+ restores the default user on that cluster's context.
149
+
150
+ ### For admins
151
+
152
+ The command expects a Desktop app OAuth client, exempted from CBA in your
153
+ access levels, limited to the scopes above, and stored as JSON (the file the
154
+ Cloud console downloads) in a Secret Manager secret your developers can read,
155
+ named `kubectl-oauth-client` in the project your `rdeploy.yaml` files name
156
+ unless you tell developers otherwise. Keep the session length short in the
157
+ app's session control, keep the control plane on a private endpoint behind
158
+ your access gateway, and leave CBA enforced for everything else.
159
+ rdeploy doesn't contain any organisation's client ID, project or cluster names.
160
+
59
161
  ## Configuration
60
162
 
61
163
  rdeploy is configured via an `rdeploy.yaml` file in your project root. The file supports versioned schemas (v1, v2, v3).
@@ -185,7 +287,7 @@ coverage report
185
287
  ## Requirements
186
288
 
187
289
  - Python 3.9+
188
- - kubectl configured with cluster access
290
+ - kubectl configured with cluster access (1.22 or later for `kubectl-login`)
189
291
  - gcloud CLI configured and authenticated
190
292
  - Helm 3.x
191
293
 
rdeploy-0.5.1/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.1