Skip to content

Commit 6d5ff2c

Browse files
HuyPhanNguyensteve-fenton-octopusclaude
authored
Document Octopus.Action.Kubernetes.VerboseOutput variable for CLI tool logging (#2993)
* Document Octopus.Action.Kubernetes.VerboseOutput variable for CLI tool logging * Fix linting errors * Fix linting errors * update variable name and description wording * tidy * fix lint --------- Co-authored-by: Steve Fenton <99181436+steve-fenton-octopus@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cca78ac commit 6d5ff2c

2 files changed

Lines changed: 46 additions & 32 deletions

File tree

src/pages/docs/kubernetes/targets/kubernetes-api/index.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ Kubernetes API targets are used by the [Kubernetes steps](/docs/deployments/kube
1313
Conceptually, a Kubernetes API target represent a permission boundary and an endpoint. Kubernetes [permissions](https://oc.to/KubernetesRBAC) and [quotas](https://oc.to/KubernetesQuotas) are defined against a namespace, and both the account and namespace are captured as a Kubernetes API target, along with the cluster endpoint URL. A namespace is required when registering the Kubernetes API target with Octopus Deploy. By default, the namespace used in the registration is used in health checks and deployments. The namespace can be overwritten in the deployment process.
1414

1515
:::div{.hint}
16-
From **Octopus 2022.2**, AKS target discovery has been added to the
17-
Kubernetes Target Discovery Early Access Preview and is enabled via **Configuration ➜ Features**.
16+
From **Octopus 2022.2**, AKS target discovery has been added to the Kubernetes Target Discovery Early Access Preview and is enabled via **Configuration ➜ Features**.
1817

1918
From **Octopus 2022.3** will include EKS cluster support.
2019
:::
2120

2221
## Discovering Kubernetes targets
2322

24-
Octopus can discover Kubernetes API targets in _Azure Kubernetes Service_ (AKS) or _Amazon Elastic Container Service for Kubernetes_ (EKS) as part of your deployment using tags on your AKS or EKS resource.
23+
Octopus can discover Kubernetes API targets in *Azure Kubernetes Service* (AKS) or *Amazon Elastic Container Service for Kubernetes* (EKS) as part of your deployment using tags on your AKS or EKS resource.
2524

2625
:::div{.hint}
2726
From **Octopus 2022.3**, you can configure the well-known variables used to discover Kubernetes targets when editing your deployment process in the Web Portal. See [cloud target discovery](/docs/infrastructure/deployment-targets/cloud-target-discovery) for more information.
@@ -87,15 +86,15 @@ users:
8786

8887
The Azure Service Principal is only used with AKS clusters. To log into ACS or ACS-Engine clusters, standard Kubernetes credentials like certificates or service account tokens must be used.
8988

90-
:::div{.hint}
89+
:::div{.hint}
9190
From Kubernetes 1.26, [the default azure auth plugin has been removed from kubectl](https://github.com/kubernetes/kubernetes/blob/ad18954259eae3db51bac2274ed4ca7304b923c4/CHANGELOG/CHANGELOG-1.26.md#deprecation) so clusters targeting Kubernetes 1.26+ that have [Local Account Access disabled](https://oc.to/AKSDisableLocalAccount) in Azure, will require the worker or execution container to have access to the [kubelogin](https://oc.to/Kubelogin) CLI tool, as well as the Octopus Deployment Target setting **Login with administrator credentials** disabled. This requires **Octopus 2023.3*.
9291

9392
If Local Account access is enabled on the AKS cluster, the Octopus Deployment Target setting Login with administrator credentials will also need to be enabled so that the Local Accounts are used instead of the default auth plugin.
9493
:::
9594

9695
- **AWS Account**: When using an EKS cluster, [AWS accounts](/docs/infrastructure/accounts/aws) allow IAM accounts and roles to be used.
9796

98-
The interaction between AWS IAM and Kubernetes Role Based Access Control (RBAC) can be tricky. We highly recommend reading the [AWS documentation](https://docs.aws.amazon.com/eks/latest/userguide/managing-auth.html).
97+
The interaction between AWS IAM and Kubernetes Role Based Access Control (RBAC) can be tricky. We highly recommend reading the [AWS documentation](https://docs.aws.amazon.com/eks/latest/userguide/managing-auth.html).
9998

10099
:::div{.hint}
101100
**Common issues:**
@@ -135,6 +134,7 @@ users:
135134
-in certificate.crt `
136135
-inkey private.key
137136
```
137+
138138
```bash
139139
#!/bin/bash
140140
echo $1 | base64 --decode > certificate.crt
@@ -154,33 +154,35 @@ users:
154154
7. Enter the Kubernetes cluster URL. Each Kubernetes target requires the cluster URL, which is defined in the `Kubernetes cluster URL` field. In the example YAML about, this is defined in the `server` field.
155155
8. Optionally, select the certificate authority if you've added one. Kubernetes clusters are often protected with self-signed certificates. In the YAML example above the certificate is saved as a base 64 encoded string in the `certificate-authority-data` field.
156156

157-
To communicate with a Kubernetes cluster with a self-signed certificate over HTTPS, you can either select the **Skip TLS verification** option, or supply the certificate in `The optional cluster certificate authority` field.
157+
To communicate with a Kubernetes cluster with a self-signed certificate over HTTPS, you can either select the **Skip TLS verification** option, or supply the certificate in `The optional cluster certificate authority` field.
158158

159-
Decoding the `certificate-authority-data` field results in a string that looks something like this (the example has been truncated for readability):
159+
Decoding the `certificate-authority-data` field results in a string that looks something like this (the example has been truncated for readability):
160160

161-
```
162-
-----BEGIN CERTIFICATE-----
163-
XXXXXXXXXXXXXXXX...
164-
-----END CERTIFICATE-----
165-
```
161+
```text
162+
-----BEGIN CERTIFICATE-----
163+
XXXXXXXXXXXXXXXX...
164+
-----END CERTIFICATE-----
165+
```
166166

167-
Save this text to a file called `ca.pem`, and upload it to the [Octopus certificate management area](https://oc.to/CertificatesDocumentation). The certificate can then be selected in the `cluster certificate authority` field.
167+
Save this text to a file called `ca.pem`, and upload it to the [Octopus certificate management area](https://oc.to/CertificatesDocumentation). The certificate can then be selected in the `cluster certificate authority` field.
168168

169169
9. Enter the Kubernetes Namespace.
170-
When a single Kubernetes cluster is shared across environments, resources deployed to the cluster will often be separated by environment and by application, team, or service. In this situation, the recommended approach is to create a namespace for each application and environment (e.g., `my-application-development` and `my-application-production`), and create a Kubernetes service account that has permissions to just that namespace.
170+
When a single Kubernetes cluster is shared across environments, resources deployed to the cluster will often be separated by environment and by application, team, or service. In this situation, the recommended approach is to create a namespace for each application and environment (e.g., `my-application-development` and `my-application-production`), and create a Kubernetes service account that has permissions to just that namespace.
171171

172-
Where each environment has its own Kubernetes cluster, namespaces can be assigned to each application, team or service (e.g. `my-application`).
172+
Where each environment has its own Kubernetes cluster, namespaces can be assigned to each application, team or service (e.g. `my-application`).
173173

174-
In both scenarios, a target is then created for each Kubernetes cluster and namespace. The `Target Role` tag is set to the application name (e.g. `my-application`), and the `Environments` are set to the matching environment.
174+
In both scenarios, a target is then created for each Kubernetes cluster and namespace. The `Target Role` tag is set to the application name (e.g. `my-application`), and the `Environments` are set to the matching environment.
175175

176-
When a Kubernetes target is used, the namespace it references is created automatically if it does not already exist.
176+
When a Kubernetes target is used, the namespace it references is created automatically if it does not already exist.
177177

178178
10. Select a worker pool for the target.
179-
To make use of the Kubernetes steps, the Octopus Server or workers that will run the steps need to have the `kubectl` executable installed. Linux workers also need to have the `jq`, `xargs` and `base64` applications installed.
179+
180+
To make use of the Kubernetes steps, the Octopus Server or workers that will run the steps need to have the `kubectl` executable installed. Linux workers also need to have the `jq`, `xargs` and `base64` applications installed.
181+
180182
11. Click **SAVE**.
181183

182184
:::div{.warning}
183-
Setting the Worker Pool in a Deployment Process will override the Worker Pool defined directly on the Deployment Target.
185+
Setting the Worker Pool in a Deployment Process will override the Worker Pool defined directly on the Deployment Target.
184186
:::
185187

186188
## Create service accounts
@@ -274,26 +276,28 @@ The token can then be saved as a Token Octopus account, and assigned to the Kube
274276

275277
:::div{.warning}
276278
Kubernetes versions 1.24+ no longer automatically create tokens for service accounts and they need to be manually created using the **create token** command:
279+
277280
```bash
278281
kubectl create token jenkins-deployer
279282
```
280283

281-
From Kubernetes version 1.29, a warning will be displayed when using automatically created Tokens. Make sure to rotate any Octopus Token Accounts to use manually created tokens via **create token** instead.
284+
From Kubernetes version 1.29, a warning will be displayed when using automatically created Tokens. Make sure to rotate any Octopus Token Accounts to use manually created tokens via **create token** instead.
282285
:::
283286

284287
## Kubectl
285288

286289
Kubernetes targets use the `kubectl` executable to communicate with the Kubernetes cluster. This executable must be available on the path on the target where the step is run. When using workers, this means the `kubectl` executable must be in the path on the worker that is executing the step. Otherwise, the `kubectl` executable must be in the path on the Octopus Server itself.
287290

288291
## Vendor Authentication Plugins {#vendor-authentication-plugins}
292+
289293
Prior to `kubectl` version 1.26, the logic for authenticating against various cloud providers (eg Azure Kubernetes Services, Google Kubernetes Engine) was included "in-tree" in `kubectl`. From version 1.26 onward, the cloud-vendor specific authentication code has been removed from `kubectl`, in favor of a plugin approach.
290294

291295
What this means for your deployments:
292296

293-
* Amazon Elastic Container Services (ECS): No change required. Octopus already supports using either the AWS CLI or the `aws-iam-authenticator` plugin.
294-
* Azure Kubernetes Services (AKS): No change required. The way Octopus authenticates against AKS clusters never used the in-tree Azure authentication code, and will continue to function as normal.
295-
- From **Octopus 2023.3**, you will need to ensure that the [kubelogin](https://oc.to/Kubelogin) CLI tool is also available if you have disabled local Kubernetes accounts.
296-
* Google Kubernetes Engine (GKE): If you upgrade to `kubectl` 1.26 or higher, you will need to ensure that the `gke-gcloud-auth-plugin` tool is also available. More information can be found on [Google's announcement about this change](https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke).
297+
- Amazon Elastic Container Services (ECS): No change required. Octopus already supports using either the AWS CLI or the `aws-iam-authenticator` plugin.
298+
- Azure Kubernetes Services (AKS): No change required. The way Octopus authenticates against AKS clusters never used the in-tree Azure authentication code, and will continue to function as normal.
299+
- From **Octopus 2023.3**, you will need to ensure that the [kubelogin](https://oc.to/Kubelogin) CLI tool is also available if you have disabled local Kubernetes accounts.
300+
- Google Kubernetes Engine (GKE): If you upgrade to `kubectl` 1.26 or higher, you will need to ensure that the `gke-gcloud-auth-plugin` tool is also available. More information can be found on [Google's announcement about this change](https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke).
297301

298302
## Helm
299303

@@ -313,6 +317,8 @@ If you're running into issues with your Kubernetes targets, it's possible you'll
313317

314318
Setting the Octopus variable `Octopus.Action.Kubernetes.OutputKubeConfig` to `True` for any deployment or runbook using a Kubernetes target will cause the generated kube config file to be printed into the logs (with passwords masked). This can be used to verify the configuration file used to connect to the Kubernetes cluster.
315319

320+
By default, successful output from Kubernetes CLI tools (`kubectl`, `helm`, `aws`, `az`, `gcloud`, etc.) is logged at the Verbose level, which is only visible when the task log level is set to Verbose. Setting the Octopus variable `Octopus.Action.Kubernetes.LogCliOutputAsInfo` to `True` will promote this output to the Info level so it appears in the Standard task log. This is useful when debugging deployments to see the full output of these tools without needing to switch the log level to Verbose for the entire deployment.
321+
316322
If Kubernetes targets fail their health checks, the best way to diagnose the issue to to run a `Run a kubectl CLI Script` step with a script that can inspect the various settings that must be in place for a Kubernetes target to function correctly. Octopus deployments will run against unhealthy targets by default, so the fact that the target failed its health check does not prevent these kinds of debugging steps from running.
317323

318324
An example script for debugging a Kubernetes target is shown below:

src/pages/docs/projects/variables/system-variables.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Build and version control details associated with the release. This is a collect
6666

6767
The `Octopus.Release.Package` and `Octopus.Release.Builds` variables:
6868

69-
- will only be populated if [build information](/docs/packaging-applications/build-servers/build-information) has been pushed from the build server.
69+
- will only be populated if [build information](/docs/packaging-applications/build-servers/build-information) has been pushed from the build server.
7070
- is only available to be used by the project [release notes](/docs/releases/release-notes), it is not accessible from the project deployment steps.
7171

7272
:::
@@ -140,11 +140,11 @@ package.Commits[685afd4161d085e6e5f56a66e72e2298e402b114].Comment
140140

141141
The variables available for commits are:
142142

143-
| Name | Example |
144-
| ---------- | ---------------------- |
145-
| `CommitId` | `#{commit.CommitId}` |
146-
| `LinkUrl` | `#{commit.LinkUrl}` |
147-
| `Comment` | `#{commit.Comment}` |
143+
| Name | Example |
144+
| ---------- | -------------------- |
145+
| `CommitId` | `#{commit.CommitId}` |
146+
| `LinkUrl` | `#{commit.LinkUrl}` |
147+
| `Comment` | `#{commit.Comment}` |
148148

149149
If the Octopus instance has one or more of the [Issue Tracker integrations](/docs/releases/issue-tracking) enabled, the commit messages will be parsed for issues. Any issues found will be displayed with the build information, and also available as variables:
150150

@@ -1116,7 +1116,7 @@ Example: *True*
11161116

11171117
The Storage URI of the \*.cspkg file that will be deployed to the Cloud Service.
11181118

1119-
Example: <https://my-storage-account/container/my-cloudservice.web.cspkg>
1119+
Example: `https://my-storage-account/container/my-cloudservice.web.cspkg`
11201120

11211121
`Octopus.Action.Azure.UseCurrentInstanceCount`
11221122

@@ -1224,7 +1224,7 @@ Example: *c9f52da2b00a4313b3b64bb2ad0f409f*
12241224

12251225
The Url of the completed Azure Cloud Service deployment.
12261226

1227-
Example: *<http://c9f52da2b00a4313b3b64bb2ad0f409f.cloudapp.net/>*
1227+
Example: `http://c9f52da2b00a4313b3b64bb2ad0f409f.cloudapp.net/`
12281228

12291229
## Step
12301230

@@ -1553,6 +1553,14 @@ Octopus will run one task at a time for a given concurrency tag. Set the variabl
15531553

15541554
Example: #{Octopus.Deployment.Tenant.Id}/#{Octopus.Project.Id}/#{Octopus.Environment.Id}
15551555

1556+
### Kubernetes
1557+
1558+
`Octopus.Action.Kubernetes.LogCliOutputAsInfo`
1559+
1560+
By default, successful output from Kubernetes CLI tools (`kubectl`, `helm`, `aws`, `az`, `gcloud`, etc.) is logged at the Verbose level, which is only visible when the task log level is set to Verbose. Set to `True` to promote this output to the Info level so it appears in the Standard task log. This is useful when debugging deployments to see the full output of these tools without needing to switch the log level to Verbose for the entire deployment.
1561+
1562+
Example: True
1563+
15561564
## Older versions {#older-versions}
15571565

15581566
- `Octopus.Release.Git.BranchName`, `Octopus.Release.Git.CommitHash` and `Octopus.Release.Git.Ref` is available from Octopus Deploy **2021.3** onwards.

0 commit comments

Comments
 (0)