Skip to content

docs: add health checks to docs & examples #4223

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 2 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions docs/ides/web-ides.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ resources in the template. With our generic model, any web application can
be used as a Coder application. For example:

```hcl
# Give template users the portainer.io web UI
# Add button to open Portainer in the workspace dashboard
# Note: Portainer must be already running in the workspace
resource "coder_app" "portainer" {
agent_id = coder_agent.main.id
name = "portainer"
icon = "https://simpleicons.org/icons/portainer.svg"
url = "http://localhost:8000"
relative_path = true
url = "https://localhost:9443/api/status"

healthcheck {
url = "https://localhost:9443/api/status"
interval = 6
threshold = 10
}
}
```

Expand Down Expand Up @@ -73,13 +79,16 @@ resource "coder_app" "code-server" {
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"

healthcheck {
url = "http://localhost:13337/healthz"
interval = 2
threshold = 10
}

}
```

<blockquote class="warning">
If the code-server integrated terminal fails to load, (i.e., xterm fails to load), go to DevTools to ensure xterm is loaded, clear your browser cache and refresh.
</blockquote>
Comment on lines -79 to -81
Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved by #3505


## JetBrains Projector

[JetBrains Projector](https://jetbrains.github.io/projector-client/mkdocs/latest/) is a JetBrains Incubator project which renders JetBrains IDEs in the web browser.
Expand All @@ -106,8 +115,6 @@ Workspace requirements:
- RubyMine
- WebStorm

- ➕ code-server (just in case!)

For advanced users who want to make a custom image, you can install the Projector CLI in the `startup_script` of the `coder_agent` resource in a Coder template. Using the Projector CLI, you can use `projector ide autoinstall` and `projector run` to download and start a JetBrains IDE in your workspace.

![IntelliJ in Coder](../images/projector-intellij.png)
Expand Down Expand Up @@ -176,7 +183,13 @@ resource "coder_app" "intellij" {
name = "${var.jetbrains-ide}"
icon = "/icon/intellij.svg"
url = "http://localhost:8997/"
relative_path = true

healthcheck {
url = "http://localhost:8997/"
interval = 6
threshold = 20
}

}
```

Expand Down Expand Up @@ -207,20 +220,31 @@ data "coder_workspace" "me" {}
## The name of the app must always be equal to the "/apps/<name>"
## string in the base_url. This caveat is unique to Jupyter.

locals {
jupyter_base_path = "/@${data.coder_workspace.me.owner}/${data.coder_workspace.me.name}/apps/jupyter/"
}

resource "coder_agent" "coder" {
os = "linux"
arch = "amd64"
dir = "/home/coder"
startup_script = <<-EOF
pip3 install jupyterlab
jupyter lab --ServerApp.base_url=/@${data.coder_workspace.me.owner}/${data.coder_workspace.me.name}/apps/jupyter/ --ServerApp.token='' --ip='*'
$HOME/.local/bin/jupyter lab --ServerApp.base_url=${local.jupyter_base_path} --ServerApp.token='' --ip='*'
EOF
}

resource "coder_app" "jupyter" {
agent_id = coder_agent.coder.id
url = "http://localhost:8888/@${data.coder_workspace.me.owner}/${data.coder_workspace.me.name}/apps/jupyter"
icon = "/icon/jupyter.svg"
name = "JupyterLab"
url = "http://localhost:8888${local.jupyter_base_path}"
icon = "/icon/jupyter.svg"

healthcheck {
url = "http://localhost:8888${local.jupyter_base_path}"
interval = 5
threshold = 10
}
}
```

Expand Down
6 changes: 6 additions & 0 deletions dogfood/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ resource "coder_app" "code-server" {
name = "code-server"
url = "http://localhost:13337/"
icon = "/icon/code.svg"

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
Copy link
Contributor

Choose a reason for hiding this comment

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

I like lowering it to 3

threshold = 10
}
}


Expand Down
6 changes: 6 additions & 0 deletions examples/templates/aws-ecs-container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@ resource "coder_app" "code-server" {
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
relative_path = true

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
threshold = 10
}
}
6 changes: 6 additions & 0 deletions examples/templates/aws-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ resource "coder_app" "code-server" {
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
threshold = 10
}
}

locals {
Expand Down
6 changes: 6 additions & 0 deletions examples/templates/bare/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ resource "coder_app" "fake-app" {
icon = "/icon/code.svg"
agent_id = "fake-compute"
url = "http://localhost:8080"

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
threshold = 10
}
}
6 changes: 6 additions & 0 deletions examples/templates/docker-code-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
url = "http://localhost:8080/?folder=/home/coder"
icon = "/icon/code.svg"

healthcheck {
url = "http://localhost:8080/healthz"
interval = 3
threshold = 10
}
}

resource "docker_volume" "home_volume" {
Expand Down
7 changes: 7 additions & 0 deletions examples/templates/docker-image-builds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ resource "coder_app" "code-server" {
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
threshold = 10
}

}

variable "docker_image" {
Expand Down
6 changes: 6 additions & 0 deletions examples/templates/gcp-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ resource "coder_app" "code-server" {
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
relative_path = true

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
threshold = 10
}
}

resource "google_compute_instance" "dev" {
Expand Down
6 changes: 6 additions & 0 deletions examples/templates/gcp-vm-container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ resource "coder_app" "code-server" {
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
relative_path = true

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
threshold = 10
}
}

module "gce-container" {
Expand Down
6 changes: 6 additions & 0 deletions examples/templates/kubernetes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ resource "coder_app" "code-server" {
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
relative_path = true

healthcheck {
url = "http://localhost:1337/healthz"
interval = 3
threshold = 10
}
}

resource "kubernetes_persistent_volume_claim" "home" {
Expand Down