The Kubernetes Grainβ
The Kubernetes grain allows you to use native Kubernetes manifests, manifest catalogs in a given user's repository. Currently, it is not possible to launch multiple concurrent environments from the same blueprint on the same namespace (because the manifest resources are static and their names are not unique).
Tools and technologiesβ
The following tools and technologies are installed out of the box on our agents in the Kubernetes pods and can be used when writing grain scripts (pre/post, etc.):
- dotnet
- curl
- kubectl
- jq
sourceβ
Please see the grain source for more details.
agentβ
Please see the grain agent for more details.
tagsββ
Whenever a Kubernetes grain is launched, all resources created during the deployment process are automatically tagged with Torque's system tags, built-in tags and custom tags. If you wish to disable tagging for all resources in a specific Kubernetes grain, use the following syntax:
grains:
database:
kind: kubernetes
spec:
tags:
auto-tag: false
Namespaceβ
Torque will install the k8s manifest in the namespace referred to in target-namespace. The target namespace must exist in the cluster prior to the deployment. It must not be equal to the namespaces used by Torque for agent deployments. Make sure the service account has enough permissions to create/read/delete everything in the manifest and also create/read/delete secrets and volumes.
helloKubernetes:
kind: kubernetes
spec:
source:
store: my-repo
path: my-asset
target-namespace: '{{ .inputs.namespace }}'
agent:
name: '{{.inputs.execution_host}}'
service-account: '{{ .inputs.service_account }}'
Note:
- Launching concurrent environments with a Kubernetes grain is not supported for the same namespace.
- Make sure the Torque agent has permissions to use those namespaces.
scripts (outputs)β
Kubernetes does not natively support outputs. Using Torque, you can overcome this and provide outputs from the manifest installation process using scripts. In this approach, the script must export environment variables. These environment variables can later be declared also as outputs. The script is defined in the blueprint and executed after the grain's installation.
For example, script named post-install-script.sh that generates two outputs:
outputs:
output1:
kind: regular
value: '{{.grains.nginx.scripts.post-kubernetes-install.outputs.output1}}'
output2:
kind: regular
value: '{{.grains.nginx.scripts.post-kubernetes-install.outputs.output2}}'
grains:
nginx:
kind: kubernetes
spec:
source:
...
namespace:
agent:
...
scripts:
post-kubernetes-install:
source:
store: Torque-Demos
path: scripts/post-install-script.sh
outputs:
- output1
- output2