Skip to content

chore(examples): update kubernetes devcontainer template with envbuilder provider #14267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2024

Conversation

johnstcn
Copy link
Member

See also: #14199

Updates the devcontainer-kubernetes template to use the coder/envbuilder provider.
Caching is completely optional here.

@johnstcn johnstcn self-assigned this Aug 14, 2024
@johnstcn johnstcn force-pushed the cj/examples/devcontainer-kubernetes branch from 15af3ce to 71c8e39 Compare August 14, 2024 09:57
@@ -222,7 +257,7 @@ resource "kubernetes_deployment" "main" {

container {
name = "dev"
image = local.devcontainer_builder_image
image = var.cache_repo == "" ? local.devcontainer_builder_image : envbuilder_cached_image.cached.0.image
image_pull_policy = "Always"
security_context {}
env {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: leaving as-is until coder/terraform-provider-envbuilder#31 is resolved.

There may be some additional Terraform jiggery pokery requried to convert local.envbuilder_env into a block list.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A for-loop would be nice here to set all the envs, wdyt?

Right now it can come from locals.envbuilder_env, but eventually from envbuilder_cached_image.cached.0.env.

env {
	for_each = locals.envbuilder_env
	name = each.key
	value = each.value
}

Not sure if tomap is required (for_each = tomap(locals.envbuilder_env)), probably not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but then that needs to be referenced in the kubernetes_pod spec below. I think that may need a dynamic{} block?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, my tf foo is not strong enough 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address this in a follow-up. The current way the envbuilder provider outputs the computed env isn't really conducive to this scenario right now anyway.

type = string
}

variable "insecure_cache_repo" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution 👍🏻

@@ -222,7 +257,7 @@ resource "kubernetes_deployment" "main" {

container {
name = "dev"
image = local.devcontainer_builder_image
image = var.cache_repo == "" ? local.devcontainer_builder_image : envbuilder_cached_image.cached.0.image
image_pull_policy = "Always"
security_context {}
env {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A for-loop would be nice here to set all the envs, wdyt?

Right now it can come from locals.envbuilder_env, but eventually from envbuilder_cached_image.cached.0.env.

env {
	for_each = locals.envbuilder_env
	name = each.key
	value = each.value
}

Not sure if tomap is required (for_each = tomap(locals.envbuilder_env)), probably not?

@johnstcn johnstcn force-pushed the cj/examples/devcontainer-kubernetes branch from 71c8e39 to 821ea40 Compare August 15, 2024 12:28
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
@johnstcn johnstcn merged commit 91a74f0 into main Aug 15, 2024
24 checks passed
@johnstcn johnstcn deleted the cj/examples/devcontainer-kubernetes branch August 15, 2024 21:08
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants