freezing-umbrella-80278
03/11/2022, 5:56 PMkubectl apply
with pulumi
.
I'm trying to install GitLab Agent on a Kubernetes cluster and the "recommended method of installation" is the following.
docker run --pull=always --rm \
<http://registry.gitlab.com/gitlab-org/cluster-integration/gitlab-agent/cli:stable|registry.gitlab.com/gitlab-org/cluster-integration/gitlab-agent/cli:stable> generate \
--agent-token=REDACTED \
--kas-address=<wss://kas.gitlab.com> \
--agent-version stable \
--namespace gitlab-kubernetes-agent | kubectl apply -f -
I was thinking I can probably run the Docker container via pulumi
and get the output of the logs as a string.
But then how can I apply that YAML with kubectl
?
I guess I could you the command package?
https://www.pulumi.com/registry/packages/command/
But not very nice as it relies on my host's installation of kubectl
and that it has access to the right cluster.billowy-army-68599
pulumi-command
provider: https://www.pulumi.com/registry/packages/command/api-docs/local/
https://www.pulumi.com/registry/packages/command/#graceful-cleanup-of-workloads-in-a-kubernetes-clusterkubectl
on stdout, you can easily convert that to pulumi as well?freezing-umbrella-80278
03/11/2022, 7:45 PMlocal.Command
.
Thanks for that example usage with kubectl
.billowy-army-68599
freezing-umbrella-80278
03/11/2022, 8:00 PMconst agentToken = config.requireSecret("gitlab-agent-token");
const gitlabAgentContainer = new docker.Container("gitlab-agent-container", {
image:
"<http://registry.gitlab.com/gitlab-org/cluster-integration/gitlab-agent/cli:stable|registry.gitlab.com/gitlab-org/cluster-integration/gitlab-agent/cli:stable>",
rm: true,
command: [
"generate",
`--agent-token=${agentToken}`,
"--kas-address=<wss://kas.gitlab.com>",
"--agent-version stable",
"--namespace gitlab-kubernetes-agent",
],
});
module.exports = {
logs: gitlabAgentContainer.containerLogs,
};
const installGitlabAgent = new local.Command("install-gitlab-agent", {
create: `echo ${gitlabAgentContainer.containerLogs} | kubectl apply -f -`,
environment: {
KUBECONFIG: provider.kubeconfig,
},
});
🤷
?billowy-army-68599
freezing-umbrella-80278
03/11/2022, 8:46 PMbillowy-army-68599
freezing-umbrella-80278
03/11/2022, 8:46 PMbillowy-army-68599
freezing-umbrella-80278
03/11/2022, 8:47 PMbillowy-army-68599
REDACTED
freezing-umbrella-80278
03/11/2022, 8:48 PMbillowy-army-68599
freezing-umbrella-80278
03/11/2022, 8:51 PMbillowy-army-68599