Skip to content

docs: restructure docs #14182

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

Closed
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
13d4f56
docs offsite day 1
bpmct May 22, 2024
3cf73ed
updated coder tour and screenshots
stirby May 23, 2024
5bcaf81
edit manifest
bpmct May 23, 2024
e97dcba
incomplete info on schedule
stirby May 23, 2024
1352640
changes
bpmct May 23, 2024
56ef29e
rebase on `main`
matifali Aug 6, 2024
d9b2b76
removed stub on coder tour
stirby May 23, 2024
de4599c
workspace README page and tour cleanup
stirby May 23, 2024
2c277df
fixed tour MD linksg
stirby May 23, 2024
ad4bb0c
replaced broken pngs
stirby May 23, 2024
920ac48
moved workspace access to a directory
stirby May 23, 2024
133721a
rebase on `main`
matifali Aug 6, 2024
762b680
workspace access docs
stirby May 23, 2024
f74f54d
user guides manifest
stirby May 23, 2024
eab79b3
rebase on `main`
matifali Aug 6, 2024
af700c3
vscode
stirby May 23, 2024
442b6fd
add schedule
bpmct May 23, 2024
c4de546
title case for user guides
stirby May 24, 2024
248bbc2
workspace scheduling
stirby May 24, 2024
48bdc86
added workspace updating to main user guide
stirby May 24, 2024
39185ed
dotfiles page done
stirby May 24, 2024
0cc2d32
fleshed out vscode page
stirby May 24, 2024
bec25cb
weekend
stirby May 26, 2024
79ee974
templates
bpmct May 24, 2024
a3f2e84
integrations
stirby May 26, 2024
c0784a4
removed other platforms page
stirby May 26, 2024
1753902
cleanup
stirby May 29, 2024
90d92e1
some reorg and writing
bpmct May 27, 2024
03f5a93
migrated guides to tutorials
stirby May 30, 2024
ee2c576
infrastructure landing page
bpmct Jun 8, 2024
2dcf91e
add guide for creating templates
bpmct Jun 8, 2024
1907108
new format
bpmct Jun 8, 2024
1215e22
consider linking to tf
bpmct Jun 8, 2024
ca1a458
install landing page
bpmct Jun 8, 2024
9b55009
post pto sync
stirby Jun 12, 2024
6267964
in flight admin-workspace changes
stirby Jun 12, 2024
13716a1
fixing images in about page
stirby Jun 12, 2024
17fcea1
reference/cli proper structure
bpmct Jun 15, 2024
fc159ce
rebase on `main`
matifali Aug 6, 2024
330132b
rebase on `main`
matifali Aug 6, 2024
1efad16
fixups for cli and api gen
bpmct Jun 15, 2024
215a3ac
modify to look for Command Line nested in manifest
bpmct Jun 15, 2024
0041e8c
rebase on `main`
matifali Aug 6, 2024
822130a
wip
matifali Aug 6, 2024
293e07c
wip
matifali Aug 6, 2024
259668b
add screenshots
bpmct Jun 15, 2024
bcfe8ba
workspace lifecycle WIP
stirby Jun 20, 2024
dd73049
added workspace lifecycle to manifest for preview
stirby Jun 20, 2024
d6f2a8c
moved resource definition outside of user guides
stirby Jun 20, 2024
15592cb
fixed manifext typo
stirby Jun 20, 2024
875274d
rough draft of workspace lifecycle
stirby Jun 20, 2024
ce0cd54
cleaned up user guide for workspace scheduling
stirby Jun 20, 2024
d47245b
linked workspace scheduling guide in workspace lifecycle
stirby Jun 20, 2024
bc7db22
started 'extending templates' rearranged resource persistence
stirby Jun 22, 2024
2da48b9
copied secrets.md under admin/security
stirby Jun 24, 2024
5d07ed9
wip
matifali Aug 6, 2024
1235238
partial completion of admin/templates/extending-templates
stirby Jun 24, 2024
22c4a55
additional extending templates refactors
stirby Jun 24, 2024
8add1d7
finished 'extending templates' with variables.md from old docs
stirby Jun 24, 2024
51365cd
added manifest for extending templates
stirby Jun 24, 2024
3a46ccd
added secrets to manifest
stirby Jun 24, 2024
6c269eb
added FAQs as a subsection of guides. Going to keep them for now.
stirby Jul 19, 2024
9ac4f3f
migrated networking docs
stirby Jul 19, 2024
cf13803
added control plane configuration docs
stirby Jul 19, 2024
4098a8c
add integration guides
matifali Aug 6, 2024
34b2ed6
fix manifest
matifali Aug 6, 2024
5ca11b0
fmt and typos
matifali Aug 6, 2024
1447aea
fixup!
matifali Aug 6, 2024
d00cc9b
fix some links
matifali Aug 6, 2024
cafa035
fixup!
matifali Aug 6, 2024
7963a1a
`make fmt`
matifali Aug 6, 2024
aa7d43c
`make gen`
matifali Aug 6, 2024
adfc34c
`make fmt`
matifali Aug 6, 2024
1d21c9a
fixup!
matifali Aug 6, 2024
5f5b3d9
fix capitalization
matifali Aug 6, 2024
4e43821
add scaling to manifest
matifali Aug 6, 2024
0d20438
fix link
matifali Aug 6, 2024
0763b35
rebase on `main`
matifali Aug 7, 2024
bf5535c
rebase on `main`
matifali Aug 7, 2024
2e4b218
fmt and typos
matifali Aug 6, 2024
0996219
`make fmt`
matifali Aug 7, 2024
990d440
`make gen`
matifali Aug 7, 2024
66ff05e
chore: bump github.com/ory/dockertest/v3 from 3.10.0 to 3.11.0 (#14237)
dependabot[bot] Aug 12, 2024
3b099fd
added workspace proxies from lost branch
stirby Aug 13, 2024
2f14a08
chore(docs): move scaling docs under admin/infrastructure (#14270)
stirby Aug 15, 2024
ad16573
chore(docs): add WebRDP to restructure docs (#14385)
stirby Aug 21, 2024
579778e
wip
matifali Aug 22, 2024
e8eb3e4
fixup!
matifali Aug 22, 2024
4b9c2c6
fmt
matifali Aug 22, 2024
01707ec
add snap
matifali Aug 22, 2024
e034239
fixup!
matifali Aug 22, 2024
c021161
fix IDEs mess
matifali Aug 22, 2024
3ef9932
fmt
matifali Aug 23, 2024
d3b4b78
link change management
matifali Aug 23, 2024
18a498d
add terraform modules
matifali Aug 23, 2024
801d4fa
delete filebrowser
matifali Aug 23, 2024
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
Prev Previous commit
Next Next commit
partial completion of admin/templates/extending-templates
  • Loading branch information
stirby authored and matifali committed Aug 12, 2024
commit 1235238c8fbf73ffd05c97eb4f755bf63f3d56b1
23 changes: 22 additions & 1 deletion docs/admin/templates/concepts.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# Extending templates

There are a variety of Coder-native features to extend the configuration of your development environments.
There are a variety of Coder-native features to extend the configuration of your development environments. Many of the following features are defined in your templates using the [Coder Terraform provider](https://registry.terraform.io/providers/coder/coder/latest/docs). The provider docs will provide code examples for usage; alternatively, you can view our [example templates](https://github.com/coder/coder/tree/main/examples/templates) to get started.

<!-- TODO: May divide into sub-pages later. -->

## Workspace agents

For users to connect to a workspace, the template must include a [`coder_agent`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent). The associated agent will facilitate [workspace connections](../../user-guides/workspace-access/README.md) via SSH, port forwarding, and IDEs. The agent may also display [workspace metadata](#agent-metadata) like resource usage.

```hcl
resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
dir = "/workspace"
display_apps {
vscode = true
}
}
```

Templates must include some computational resource to start the agent. All processes on the workspace are then spawned from the agent. All information in the dashboard's workspace view is pulled from the agent.

![A healthy workspace agent](../../images/templates/healthy-workspace-agent.png)

Multiple agents may be used in a single template or even a single resource. Each agent may have it's own apps, startup script, and metadata. This can be used to associate multiple containers or VMs with a workspace.

## Resource persistence

The resources you define in a template may be _ephemeral_ or _persistent_. Persistent resources stay provisioned when workspaces are stopped, where as ephemeral resources are destroyed and recreated on restart. All resources are destroyed when a workspace is deleted.
Expand All @@ -21,6 +40,8 @@ A common configuration is a template whose only persistent resource is the home

## Template variables



## Parameters

## Coder apps
Expand Down
70 changes: 70 additions & 0 deletions docs/admin/templates/extending-templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Extending templates

There are a variety of Coder-native features to extend the configuration of your development environments. Many of the following features are defined in your templates using the [Coder Terraform provider](https://registry.terraform.io/providers/coder/coder/latest/docs). The provider docs will provide code examples for usage; alternatively, you can view our [example templates](https://github.com/coder/coder/tree/main/examples/templates) to get started.

<!-- TODO: Review structure

extending-templates/
README.md
- workspace agent overview
- resource persistence
- coder apps
- coder parameters
- template variables
agent-metadata.md (from old docs)
resource-metadata.md (from old docs)
resource-ordering.md (from old docs)
-->

## Workspace agents

For users to connect to a workspace, the template must include a [`coder_agent`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent). The associated agent will facilitate [workspace connections](../../../user-guides/workspace-access/README.md) via SSH, port forwarding, and IDEs. The agent may also display [workspace metadata](#agent-metadata) like resource usage.

```hcl
resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
dir = "/workspace"
display_apps {
vscode = true
}
}
```

Templates must include some computational resource to start the agent. All processes on the workspace are then spawned from the agent. All information in the dashboard's workspace view is pulled from the agent.

![A healthy workspace agent](../../../images/templates/healthy-workspace-agent.png)

Multiple agents may be used in a single template or even a single resource. Each agent may have it's own apps, startup script, and metadata. This can be used to associate multiple containers or VMs with a workspace.

## Resource persistence

The resources you define in a template may be _ephemeral_ or _persistent_. Persistent resources stay provisioned when workspaces are stopped, where as ephemeral resources are destroyed and recreated on restart. All resources are destroyed when a workspace is deleted.

> You can read more about how resource behavior and workspace state in the [workspace lifecycle documentation](../../workspaces/lifecycle.md).

Template resources follow the [behavior of Terraform resources](https://developer.hashicorp.com/terraform/language/resources/behavior#how-terraform-applies-a-configuration) and can be further configured  using the [lifecycle argument](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle).

### Example usage

A common configuration is a template whose only persistent resource is the home directory. This allows the developer to retain their work while ensuring the rest of their environment is consistently up-to-date on each workspace restart.


## Template variables

You can show live operational metrics to workspace users with agent metadata. It is the dynamic complement of resource metadata.

You specify agent metadata in the coder_agent.

## Parameters

## Coder apps

### App ordering

## Agent metadata


<children>

</children>
148 changes: 148 additions & 0 deletions docs/admin/templates/extending-templates/agent-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Agent metadata

![agent-metadata](../../../images/admin/templates/agent-metadata-ui.png)

You can show live operational metrics to workspace users with agent metadata. It
is the dynamic complement of [resource metadata](./resource-metadata.md).

You specify agent metadata in the
[`coder_agent`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent).

## Examples

All of these examples use
[heredoc strings](https://developer.hashicorp.com/terraform/language/expressions/strings#heredoc-strings)
for the script declaration. With heredoc strings, you can script without messy
escape codes, just as if you were working in your terminal.

Some of the examples use the [`coder stat`](../../../reference/cli/stat.md) command. This is
useful for determining CPU and memory usage of the VM or container that the
workspace is running in, which is more accurate than resource usage about the
workspace's host.

Here's a standard set of metadata snippets for Linux agents:

```hcl
resource "coder_agent" "main" {
os = "linux"
...
metadata {
display_name = "CPU Usage"
key = "cpu"
# Uses the coder stat command to get container CPU usage.
script = "coder stat cpu"
interval = 1
timeout = 1
}

metadata {
display_name = "Memory Usage"
key = "mem"
# Uses the coder stat command to get container memory usage in GiB.
script = "coder stat mem --prefix Gi"
interval = 1
timeout = 1
}

metadata {
display_name = "CPU Usage (Host)"
key = "cpu_host"
# calculates CPU usage by summing the "us", "sy" and "id" columns of
# top.
script = <<EOT
top -bn1 | awk 'FNR==3 {printf "%2.0f%%", $2+$3+$4}'
EOT
interval = 1
timeout = 1
}

metadata {
display_name = "Memory Usage (Host)"
key = "mem_host"
script = <<EOT
free | awk '/^Mem/ { printf("%.0f%%", $4/$2 * 100.0) }'
EOT
interval = 1
timeout = 1
}

metadata {
display_name = "Disk Usage"
key = "disk"
script = "df -h | awk '$6 ~ /^\\/$/ { print $5 }'"
interval = 1
timeout = 1
}

metadata {
display_name = "Load Average"
key = "load"
script = <<EOT
awk '{print $1,$2,$3}' /proc/loadavg
EOT
interval = 1
timeout = 1
}
}
```

## Useful utilities

You can also show agent metadata for information about the workspace's host.

[top](https://manpages.ubuntu.com/manpages/jammy/en/man1/top.1.html) is
available in most Linux distributions and provides virtual memory, CPU and IO
statistics. Running `top` produces output that looks like:

```text
%Cpu(s): 65.8 us, 4.4 sy, 0.0 ni, 29.3 id, 0.3 wa, 0.0 hi, 0.2 si, 0.0 st
MiB Mem : 16009.0 total, 493.7 free, 4624.8 used, 10890.5 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 11021.3 avail Mem
```

[vmstat](https://manpages.ubuntu.com/manpages/jammy/en/man8/vmstat.8.html) is
available in most Linux distributions and provides virtual memory, CPU and IO
statistics. Running `vmstat` produces output that looks like:

```text
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 19580 4781680 12133692 217646944 0 2 4 32 1 0 1 1 98 0 0
```

[dstat](https://manpages.ubuntu.com/manpages/jammy/man1/dstat.1.html) is
considerably more parseable than `vmstat` but often not included in base images.
It is easily installed by most package managers under the name `dstat`. The
output of running `dstat 1 1` looks like:

```text
--total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai stl| read writ| recv send| in out | int csw
1 1 98 0 0|3422k 25M| 0 0 | 153k 904k| 123k 174k
```

## Managing the database load

Agent metadata can generate a significant write load and overwhelm your Coder
database if you're not careful. The approximate writes per second can be
calculated using the formula:

```text
(metadata_count * num_running_agents * 2) / metadata_avg_interval
```

For example, let's say you have

- 10 running agents
- each with 6 metadata snippets
- with an average interval of 4 seconds

You can expect `(10 * 6 * 2) / 4`, or 30 writes per second.

One of the writes is to the `UNLOGGED` `workspace_agent_metadata` table and the
other to the `NOTIFY` query that enables live stats streaming in the UI.

## Next Steps

- [Resource metadata](./resource-metadata.md)
- [Parameters](./parameters.md)
80 changes: 80 additions & 0 deletions docs/admin/templates/extending-templates/icons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Icons

Coder uses icons in several places, including ones that can be configured
throughout the app, or specified in your Terraform. They're specified by a URL,
which can be to an image hosted on a CDN of your own, or one of the icons that
come bundled with your Coder deployment.

- **Template Icons**:

- Make templates and workspaces visually recognizable with a relevant or
memorable icon

- [**Terraform**](https://registry.terraform.io/providers/coder/coder/latest/docs):

- [`coder_app`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/app#icon)
- [`coder_parameter`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter#icon)
and
[`option`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter#nested-schema-for-option)
blocks
- [`coder_script`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/script#icon)
- [`coder_metadata`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/metadata#icon)

These can all be configured to use an icon by setting the `icon` field.

```hcl
data "coder_parameter" "my_parameter" {
icon = "/icon/coder.svg"

option {
icon = "/emojis/1f3f3-fe0f-200d-26a7-fe0f.png"
}
}
```

- [**Authentication Providers**](https://coder.com/docs/v2/latest/admin/external-auth):

- Use icons for external authentication providers to make them recognizable.
You can set an icon for each provider by setting the
`CODER_EXTERNAL_AUTH_X_ICON` environment variable, where `X` is the number
of the provider.

```env
CODER_EXTERNAL_AUTH_0_ICON=/icon/github.svg
CODER_EXTERNAL_AUTH_1_ICON=/icon/google.svg
```

- [**Support Links**](../admin/appearance.md#support-links):

- Use icons for support links to make them recognizable. You can set the
`icon` field for each link in `CODER_SUPPORT_LINKS` array.

## Bundled icons

Coder is distributed with a bundle of icons for popular cloud providers and
programming languages. You can see all of the icons (or suggest new ones) in our
repository on
[GitHub](https://github.com/coder/coder/tree/main/site/static/icon).

You can also view the entire list, with search and previews, by navigating to
/icons on your Coder deployment. E.g. [https://coder.example.com/icons](#). This
can be particularly useful in airgapped deployments.

![The icon gallery](../images/icons-gallery.png)

## External icons

You can use any image served over HTTPS as an icon, by specifying the full URL
of the image. We recommend that you use a CDN that you control, but it can be
served from any source that you trust.

You can also embed an image by using data: URLs.

- Only the https: and data: protocols are supported in icon URLs (not http:)

- Be careful when using images hosted by someone else; they might disappear or
change!

- Be careful when using data: URLs. They can get rather large, and can
negatively impact loading times for pages and queries they appear in. Only use
them for very small icons that compress well.
Loading