Skip to content

Commit

Permalink
Add more documentation for resources
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjackson committed May 8, 2023
1 parent 1ef56f9 commit cd058bb
Show file tree
Hide file tree
Showing 15 changed files with 1,183 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/config/navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,24 @@ export const navigation = [
title: 'Resources',
links: [
{ title: 'Overview', href: '/docs/resources/overview' },
{ title: 'Certificate', href: '/docs/resources/certificate' },
{ title: 'Copy', href: '/docs/resources/copy' },
{ title: 'Docs', href: '/docs/resources/docs' },
{ title: 'Container', href: '/docs/resources/container' },
{ title: 'Nomad Cluster', href: '/docs/resources/nomad_cluster' },
{ title: 'Nomad Job', href: '/docs/resources/nomad_job' },
{ title: 'Helm', href: '/docs/resources/helm' },
{ title: 'Ingress', href: '/docs/resources/ingress' },
{ title: 'Kubernetes Cluster', href: '/docs/resources/kubernetes_cluster' },
{ title: 'Kubernetes Config', href: '/docs/resources/kubernetes_config' },
{ title: 'Local Exec', href: '/docs/resources/local_exec' },
{ title: 'Module', href: '/docs/resources/module' },
{ title: 'Network', href: '/docs/resources/network' },
{ title: 'Output', href: '/docs/resources/output' },
{ title: 'Remote Exec', href: '/docs/resources/local_exec' },
{ title: 'Sidecar', href: '/docs/resources/sidecar' },
{ title: 'Template', href: '/docs/resources/template' },
{ title: 'Variables', href: '/docs/resources/variables' },
]
}
]
7 changes: 7 additions & 0 deletions src/pages/docs/resources/certificate.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Certificate

<Intro>
Documentation is work in progress, please see the old documentation at:

https://shipyard.run/docs/resources/certificate
</Intro>
7 changes: 7 additions & 0 deletions src/pages/docs/resources/copy.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copy `copy`

<Intro>
Documentation is work in progress, please see the old documentation at:

https://shipyard.run/docs/resources/copy
</Intro>
7 changes: 7 additions & 0 deletions src/pages/docs/resources/docs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Docs `docs`

<Intro>
Documentation is work in progress, please see the old documentation at:

https://shipyard.run/docs/resources/docs
</Intro>
38 changes: 38 additions & 0 deletions src/pages/docs/resources/example.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import MetaProperties from "./shared/meta.mdx"

# Example `example`

<Intro>
The Remove Exec resource allows the execution of arbitrary commands and scripts.
Execution can either be in a stand alone container or can target an existing
and running container.

Documentation is work in progress, please see the old documentation at:

https://shipyard.run/docs/resources/exec_remote
</Intro>

## Properties

<Properties>
<Property name="cluster" type="string" required="true" value="" readonly>
Text

```hcl
code
```
</Property>

<Property name="cluster" type="string" required="true" value="" readonly>
Text
</Property>
</Properties>

<MetaProperties/>

## Examples

### Example 1

```hcl
```
85 changes: 85 additions & 0 deletions src/pages/docs/resources/helm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import MetaProperties from "./shared/meta.mdx"

# Helm `helm`

<Intro>
The `helm` resource allows Helm charts to be provisioned to `k8s_cluster` resources.

Documentation is work in progress, please see the old documentation at:

https://shipyard.run/docs/resources/exec_remote
</Intro>

## Properties

<Properties>
<Property name="cluster" type="string" required="true" value="" readonly>
Text

```hcl
code
```
</Property>

<Property name="cluster" type="string" required="true" value="" readonly>
Text
</Property>
</Properties>

<MetaProperties/>

## Examples

### Install Helm Chart from a Helm Repository

```hcl
resource "helm" "consul" {
cluster = resource.k8s_cluster.k3s.id
repository {
name = "hashicorp"
url = "https://helm.releases.hashicorp.com"
}
chart = "hashicorp/consul"
version = "v0.40.0"
values = "./helm/consul-values.yaml"
health_check {
timeout = "240s"
pods = [
"component=connect-injector",
"component=client",
"component=controller",
"component=server",
]
}
}
```

### Install Helm Chart from a GitHub Repository

```hcl
resource "helm" "vault" {
cluster = resource.k8s_cluster.k3s.id
chart = "github.com/hashicorp/vault-helm"
values_string = {
"server.dataStorage.size" = "128Mb"
}
}
```

### Install Helm Chart from a Local Folder

```hcl
resource "helm" "vault" {
cluster = resource.k8s_cluster.k3s.id
chart = "./files/helm/vault"
values_string = {
"server.dataStorage.size" = "128Mb"
}
}
```
31 changes: 31 additions & 0 deletions src/pages/docs/resources/kubernetes_config.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Kubernetes Configuration `k8s_config`

<Intro>
The k8s_config resource allows Kubernetes configuraton to be applied on a k8s_cluster.
You can specify a list of paths or individual files and health checks for the resources.
A k8s_config only completes once the configuration has bene successfully
applied and any health checks have passed. This allows you to create complex
dependencies for your applications.


Documentation is work in progress, please see the old documentation at:

https://shipyard.run/docs/resources/k8s_config
</Intro>

## Properties

## Examples

```hcl
resource "k8s_config" "app" {
cluster = resource.k8s_cluster.k3s.id
paths = [
"./k8s_config/app",
"./k8s_config/dashboard",
]
wait_until_ready = true
}
```
79 changes: 79 additions & 0 deletions src/pages/docs/resources/local_exec.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import MetaProperties from "./shared/meta.mdx"

# Local Exec `local_exec`

<Intro>
The `local_exec` resource allows the execution of arbitrary commands and scripts
on the local machine. The command runs in the local user space, and has access
to all the environment variables that the user executing shipyard run has access
too. Additional environment variables, and the working directory for the command
can be specified as part of the resource.

Log files for exec_local are written to $HOME\.jumppad\logs\[name].log

Documentation is work in progress, please see the old documentation at:

https://shipyard.run/docs/resources/exec_local
</Intro>

## Properties

<Properties>
<Property name="cluster" type="string" required="true" value="" readonly>
Text

```hcl
code
```
</Property>

<Property name="cluster" type="string" required="true" value="" readonly>
Text
</Property>
</Properties>

<MetaProperties/>

## Examples

### Minimal Example

The following example will run the command consul services register ./config/redis/hcl
and will wait for it to complete. If the command takes longer than 30s to complete,
it will be automatically killed.

```hcl
resource "local_exec" "exec_standalone" {
command = [
"consul"
"services",
"register",
"./config/redis.hcl"
]
environment = {
CONSUL_HTTP_ADDR = "http://consul.container.shipyard.run:8500"
}
timeout = "30s"
}
```

### Daemon Mode
The following example runs the command consul agent -dev and immediately returns
leaving the command to run as a daemon which is not terminated when the shipyard
run command completes.

Daemons either exit on their own or are killed when running shipyard destroy.

```hcl
resource remote_exec "exec_standalone" {
command = [
"consul"
"agent",
"-dev",
]
daemon = true
}
```
89 changes: 89 additions & 0 deletions src/pages/docs/resources/module.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import MetaProperties from "./shared/meta.mdx"

# Module `module`

<Intro>
The `module` resource allows a blueprint to reference other files or blueprints.
Blueprints can be referenced from the local file system or from GitHub repositories.

All resources contained within a module are scoped to the name of the containing
module. For example, if a module `mine` contains a kubernetes cluster called `dev`
then the FQRN and the name within docker would be:

`server.dev.mine.k8s-cluster.jumppad.dev`

Modules can also contain modules, to ensure that resouce references are unique
resources always take on the name of their module including any parent modules.

For example, if a module `mine` contains a kubernetes cluster called `dev` was
contained in module `parent`. Then the FQRN and the name within docker would be:

`server.dev.parent.mine.k8s-cluster.jumppad.dev`
</Intro>

## Properties

<Properties>
<Property name="source" type="string" required="true" value="">
The source of the module, can either be a local file or GitHub repositories
or remote archive.
</Property>

<Property name="variables" type="map[string]interface" required="false" value="">
Module can define `variables` making them dynamic, `variables` are scoped
to each module meaning that any variable that is set globally will not be
readable to modules or submodules. To set variables defined inside a module
use the `varaibles` block

```hcl
variables = {
network_id = resource.network.cloud.id
consul_port = 18501
}
```
</Property>
</Properties>

<MetaProperties/>

## Examples

### Module Reuse

The following example shows how a module can be used multiple times.

```hcl
resource "network" "cloud" {
subnet = "10.5.0.0/16"
}
module "consul_dc1" {
source = "./module_k3s"
variables = {
network_id = resource.network.cloud.id
consul_port = 18500
}
}
module "consul_dc2" {
// CI has limited resources, add a manual dependency to ensure that only one module
// is created at once
depends_on = ["module.consul_dc1"]
source = "./module_k3s"
variables = {
network_id = resource.network.cloud.id
consul_port = 18501
}
}
output "dc1_addr" {
value = module.consul_dc1.output.consul_http_addr
}
output "dc2_addr" {
value = module.consul_dc2.output.consul_http_addr
}
```
Loading

0 comments on commit cd058bb

Please sign in to comment.