Skip to content

Commit

Permalink
chore: upgrade to nanocl 0.10 version
Browse files Browse the repository at this point in the history
  • Loading branch information
leon3s committed Oct 5, 2023
1 parent c565805 commit c2847c7
Show file tree
Hide file tree
Showing 26 changed files with 1,925 additions and 565 deletions.
66 changes: 66 additions & 0 deletions docs/guides/nanocl/advanced-usage/secret_env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Secret Env | Nanocl
description: Use secret in your .
keywords: [documentation, nanocl, guides, get started, configuration, state, file, config, yaml, yml, statefile, ssl, tls, certificate]
image: /img/logo.webp
sidebar_position: 0
sidebar_label: Secret Env
pagination_next: null
---

# Secret Env

You can create `Secret` to pass then as environement variable for your `Cargoes`.<br/>

:::tip
You can create secrets directly from a deployment `Statefile`!<br/>
But i recommand you to use `Secret` kind of Statefile and manage them separatly.
:::

There is an `Statefile` example on how to do it:

```yaml
Kind: Deployment
ApiVersion: v0.10

Namespace: global

# See all options:
# https://docs.next-hat.com/references/nanocl/secret
Secrets:
- Key: env.my-secret
Kind: Env
Data:
- MY_ENV=MY_VALUE
- MY_ENV1=MY_VALUE1

# See all options:
# https://docs.next-hat.com/references/nanocl/cargo
Cargoes:
- Name: my-cargo
# Specify what secrets to use
Secrets:
- env.my-secret
Container:
Image: nexthat/nanocl-get-started:latest

# See all options:
# https://docs.next-hat.com/references/nanocl/resource
Resources:
- Name: deploy-example.com
Kind: ProxyRule
Version: v0.7
Data:
Rules:
- Domain: deploy-example.com
Network: Public
# Enable usage of our secret
Ssl: cert.deploy-example.com
Locations:
- Path: /
Target:
Key: my-cargo.global.c
Port: 9000
```
For more information about secrets refer to our [Secret reference](/references/nanocl/secret)
155 changes: 155 additions & 0 deletions docs/guides/nanocl/advanced-usage/secret_tls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
title: Secret TLS | Nanocl
description: Use TLS to protect your services.
keywords: [documentation, nanocl, guides, get started, configuration, state, file, config, yaml, yml, statefile, ssl, tls, certificate]
image: /img/logo.webp
sidebar_position: 1
sidebar_label: Secret TLS
pagination_next: null
---

# Secret TLS

To add an SSL Certificate you must create a secret.<br/>

## Manual Setup

:::tip
You can create secrets directly from a deployment `Statefile`!<br/>
But i recommand you to use `Secret` kind of Statefile and manage them separatly.
:::

There is an `Statefile` example on how to do it:

```yaml
Kind: Deployment
ApiVersion: v0.10

Namespace: global

Secrets:
- Key: cert.deploy-example.com
Kind: Tls
Data:
Certificate: |
-----BEGIN CERTIFICATE-----
MIIDETCCAfkCFFOJVQs8PxWlcJQDn/AQpSopkhISMA0GCSqGSIb3DQEBCwUAMEUx
CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl
cm5ldCBXaWRnaXRzIFB0eSBMdGQwHhcNMjMwNTI5MDM0MDQwWhcNMjQwNTI4MDM0
MDQwWjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UE
CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEAyH+TAzIAxxrMKh88p1emIxsttpjqCHdlQuboves+0vI6ORwU
BI3HP7gTMQpgK+QnEZw1XIs6/Zdg2VfUiNgQXyh72/0cdurIIqRbF2fLAMSaYElA
RRT9F60eHqQ12bXf6ITWB/0ZSnacbLIsic1HcVwr0Awx+xu1YsB9ojssXyIIU/yx
d6FjPtiqJTPT9RhVb6Vmfpclse21qGek8tg88U+TrrJZ/Eg5cZojnQTyxhMGHeQf
F71nb7no1v5hdki3p50Ik//9lvY/5onWrBUCuAsHi8OkSSyElTQ/JYzuMBjqOaMw
PYLZf3d2eRqpiEC/5WI8OJDAk3/y83nG3zy3+QIDAQABMA0GCSqGSIb3DQEBCwUA
A4IBAQAz8b7U0jbgBVEen1vd15V6DAxTmg768OkMRoNqK/y0oSK0qHn3IYSADK6M
fl6qPnTY3xts+j8ohvNRGR5rJiv25b8koQs6K/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VnL+KXD7cTA7DQq4ma/7UlJMaxhuA11w/4wF/lRiXKNUTfpUSyIybT8IP23fgFDV
zLq2G36+mpUXbxPjlFaJfxNOlcr35xvsIC3HMBqOKYm74B9rJbLIwsMZcPi/BuJS
ve7pj9blvjf8ZUXw8erhFFoGUwKBgQDyr+u7OQyIhqhCOpy9Is/DtYBg3MQSDLTO
TfmqaaUcDvRNy4pgJ2B5Kbs20yAqgBtGDEP+MdtBo3NgIHOA7xjU5biNSz8R12WR
UmDrdxIvAo2iixN8TDvIs0EEmE5hrRgPRaf6WP3o1okaWnYuq2VC7HSJJFCtWx9V
Aj7VEOgnAwKBgGAXWdshVvc+9L1RfDKqRHTVv09+jbtGoahdq2c0b8/omKDjRoEg
mi3e79gA3vReuW2y9UaT/B9zMihp1FBPREWZGGzhLvwGq7Kqoua1pb/+rskTZ8xQ
knv9jxMoLDwACEZWSnSMiLf2bA3ewtV1FidoAus/EZDLMovWXjEFXiGhAoGBAIGb
YhGCzia7g3CbTMnVpY+nhwAz5qKdFpJ3IjbYZM0vT1mcsjHX1bXfi5Qj/LG16Nro
AgfnKGlNmXhk3EqnZmOMq5sJ7Izis+OAUzJtTNC+VFXSYH2pWOQ+lyKVFIclogvF
74fLrw6CRIZGeYdDEblD/pifRFbQq1MC9/tiJBlxAoGAAo/XDJSTRlcrJuutk5jG
CZPG5LBlxvdUbsuu2vZ7XIoWp3BvuK+yM8m9kEQgl3x8F3bqRjoQmMN6cImMYC2W
F02Hw2EcWWx4w+liGjDy8/rcb9KfYTht3Q3W9RYYPZwn+hg4pmGVb4+yOqd183QQ
Ug0MvH79P7CUpecFPJliDME=
-----END PRIVATE KEY-----
# See all options:
# https://docs.next-hat.com/references/nanocl/cargo
Cargoes:
- Name: my-cargo
Container:
Image: nexthat/nanocl-get-started:latest

# See all options:
# https://docs.next-hat.com/references/nanocl/resource
Resources:
- Name: deploy-example.com
Kind: ProxyRule
Version: v0.7
Data:
Rules:
- Domain: deploy-example.com
Network: Public
# Enable usage of our secret
Ssl: cert.deploy-example.com
Locations:
- Path: /
Target:
Key: my-cargo.global.c
Port: 9000
```
## Automatic with Let's Encrypt
You can use [certbot](https://certbot.eff.org/) to generate a certificate for your domain.<br/>
To do so we crafted a generic `Statefile` for you that can handle the job and create a proper `secret`.<br/>
The secret will be named as follow: `cert.{domain_name}`.<br/>

```sh
nanocl state apply -s nhnr.io/sys/certbot.yml -f -- --email your@email.com --domain deploy-example.com
```

After the command finished Ssl will be enabled already but you need to update your `ProxyRule`.<br/>
To use the `secret` for your next deployment:

```yaml
Kind: Deployment
ApiVersion: v0.10
Namespace: global
# See all options:
# https://docs.next-hat.com/references/nanocl/cargo
Cargoes:
- Name: my-cargo
Container:
Image: nexthat/nanocl-get-started:latest
# See all options:
# https://docs.next-hat.com/references/nanocl/resource
Resources:
- Name: deploy-example.com
Kind: ProxyRule
Version: v0.7
Data:
Rules:
- Domain: deploy-example.com
Network: Public
# Enable usage of our secret
Ssl: cert.deploy-example.com
Locations:
- Path: /
Target:
Key: my-cargo.global.c
Port: 9000
```

For more information about secrets refer to our [Secret reference](/references/nanocl/secret)
104 changes: 0 additions & 104 deletions docs/guides/nanocl/advanced-usage/ssl.md

This file was deleted.

40 changes: 21 additions & 19 deletions docs/guides/nanocl/advanced-usage/state-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ Let considere this example, create a new file called `my-deployment.yml` and add

```yml
Kind: Deployment
ApiVersion: v0.9
ApiVersion: v0.10

# Definition of your arguments
Args:
- Name: name
Kind: String # Only available value is String for now
# The type of argument, can be:
# - String
# - Number
# - Boolean
Kind: String
- Name: domain
Kind: String
- Name: image
Expand All @@ -31,25 +35,23 @@ Args:
Namespace: global

Cargoes:
- Name: ${{ Args.name }}
Container:
Image: ${{ Args.image }}
- Name: ${{ Args.name }}
Container:
Image: ${{ Args.image }}

Resources:
- Name: ${{ Args.domain }}
Kind: ProxyRule
Version: v0.5
Config:
Watch:
- ${{ Args.name }}.global.c
Rules:
- Domain: ${{ Args.domain }}
Network: Public
Locations:
- Path: /
Target:
Key: ${{ Args.name }}.global.c
Port: ${{ Args.port }}
- Name: ${{ Args.domain }}
Kind: ProxyRule
Version: v0.10
Data:
Rules:
- Domain: ${{ Args.domain }}
Network: Public
Locations:
- Path: /
Target:
Key: ${{ Args.name }}.global.c
Port: ${{ Args.port }}
```
Now if you apply it with:
Expand Down
Loading

0 comments on commit c2847c7

Please sign in to comment.