Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Update examples in readme
  • Loading branch information
Erik Veld authored Aug 3, 2023
1 parent 527f8f7 commit bae8ca5
Showing 1 changed file with 129 additions and 79 deletions.
208 changes: 129 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,131 +37,181 @@ The following snippets are examples of things you can build with Jumppad, for mo
### Kubernetes Cluster

```hcl
k8s_cluster "k3s" {
driver = "k3s" // default
resource "network" "cloud" {
subnet = "10.5.0.0/16"
}
resource "k8s_cluster" "k3s" {
driver = "k3s" // default
nodes = 1 // default
network {
name = "network.cloud"
id = resource.network.cloud.id
}
copy_image {
name = "shipyardrun/connector:v0.1.0"
}
}
helm "consul" {
cluster = "k8s_cluster.k3s"
chart = "./helm/consul-helm-0.16.2"
values = "./helm/consul-values.yaml"
resource "k8s_config" "fake_service" {
cluster = resource.k8s_cluster.k3s.id
paths = ["./fake_service.yaml"]
health_check {
timeout = "60s"
pods = ["release=consul"]
timeout = "240s"
pods = ["app.kubernetes.io/name=fake-service"]
}
}
k8s_ingress "consul-http" {
cluster = "k8s_cluster.k3s"
service = "consul-consul-server"
resource "helm" "vault" {
cluster = resource.k8s_cluster.k3s.id
network {
name = "network.cloud"
repository {
name = "hashicorp"
url = "https://helm.releases.hashicorp.com"
}
port {
local = 8500
remote = 8500
host = 18500
chart = "hashicorp/vault"
version = "v0.18.0"
values = "./helm/vault-values.yaml"
health_check {
timeout = "240s"
pods = ["app.kubernetes.io/name=vault"]
}
}
```
### Nomad Cluster
resource "ingress" "vault_http" {
port = 18200
```hcl
nomad_cluster "dev" {
version = "v0.10.2"
target {
id = resource.k8s_cluster.k3s.id
port = 8200
nodes = 1 // default
network {
name = "network.cloud"
config = {
service = "vault"
namespace = "default"
}
}
}
nomad_job "redis" {
cluster = "nomad_cluster.dev"
resource "ingress" "fake_service" {
port = 19090
paths = ["./app_config/example2.nomad"]
health_check {
timeout = "60s"
nomad_jobs = ["example_2"]
target {
id = resource.k8s_cluster.k3s.id
port = 9090
config = {
service = "fake-service"
namespace = "default"
}
}
}
nomad_ingress "nomad-http" {
cluster = "nomad_cluster.dev"
job = ""
group = ""
task = ""
port {
local = 4646
remote = 4646
host = 14646
open_in_browser = "/"
}
output "VAULT_ADDR" {
value = resource.ingress.vault_http.address
}
network {
name = "network.cloud"
}
output "KUBECONFIG" {
value = resource.k8s_cluster.k3s.kubeconfig
}
```

### Docker Container
### Nomad Cluster

```hcl
container "consul" {
image {
name = "consul:1.6.1"
}
command = ["consul", "agent", "-config-file=/config/consul.hcl"]
resource "network" "cloud" {
subnet = "10.10.0.0/16"
}
volume {
source = "./consul_config"
destination = "/config"
}
resource "nomad_cluster" "dev" {
client_nodes=3
network {
name = "network.onprem"
ip_address = "10.5.0.200" // optional
id = resource.network.cloud.id
}
}
resources {
# Max CPU to consume, 1024 is one core, default unlimited
cpu = 2048
# Pin container to specified CPU cores, default all cores
cpu_pin = [1,2]
# max memory in MB to consume, default unlimited
memory = 1024
}
resource "nomad_job" "example_1" {
cluster = resource.nomad_cluster.dev.id
env {
key ="abc"
value = "123"
}
paths = ["./app_config/example1.nomad"]
env {
key ="SHIPYARD_FOLDER"
value = "${shipyard()}"
health_check {
timeout = "60s"
nomad_jobs = ["example_1"]
}
}
resource "ingress" "fake_service_1" {
port = 19090
env {
key ="HOME_FOLDER"
value = "${home()}"
target {
id = resource.nomad_cluster.dev.id
named_port = "http"
config = {
job = "example_1"
group = "fake_service"
task = "fake_service"
}
}
}
```

### Docker Container

```hcl
resource "container" "unique_name" {
depends_on = ["resource.container.another"]
network {
id = resource.network.cloud.id
ip_address = "10.16.0.200"
aliases = ["my_unique_name_ip_address"]
}
image {
name = "consul:1.6.1"
username = "repo_username"
password = "repo_password"
}
command = [
"consul",
"agent"
]
environment = {
CONSUL_HTTP_ADDR = "http://localhost:8500"
}
volume {
source = "./config"
destination = "/config"
}
port {
local = 8500
remote = 8500
host = 18500
}
port_range {
range = "9000-9002"
enable_host = true
}
privileged = false
}
```

## Podman support

Podman support is experimental and at present many features such as Kubernetes clusters do not work with rootless podman and require root access.
Expand Down

0 comments on commit bae8ca5

Please sign in to comment.