Skip to content

Commit 37f8b24

Browse files
committed
Errand: Naming standards, Deployment of the containers, Dependency and Readiness
1 parent 16a34e2 commit 37f8b24

14 files changed

Lines changed: 227 additions & 11 deletions

File tree

docs/definitions/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"label": "Definitions",
3-
"position": 4,
3+
"position": 5,
44
"link": {
55
"type": "generated-index",
66
"description": "Learn what resources are available."

docs/deployment/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"label": "Container deployment",
3-
"position": 3,
3+
"position": 4,
44
"link": {
55
"type": "generated-index",
66
"description": "Learn how to deploy container and other resources."

docs/deployment/plain.md

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,114 @@
22
sidebar_position: 5
33
---
44

5-
# Plain
5+
# Containers deployment
6+
## Minimal deployment
7+
To deploy container with minimal configuration, definition below is enough:
8+
```cgo
9+
prefix: simplecontainer.io/v1
10+
kind: containers
11+
meta:
12+
group: example
13+
name: busybox
14+
spec:
15+
image: busybox
16+
tag: latest
17+
replicas: 1
18+
entrypoint: ["sleep"]
19+
args: ["3600"]
20+
```
21+
Entrypoint and args are additional configuration so that container keeps alive.
22+
23+
```bash
24+
smrctl apply https://raw.githubusercontent.com/simplecontainer/examples/refs/heads/main/tests/minimal/definitions/Containers.yaml
25+
```
26+
This deploys busybox container.
27+
28+
## Readiness and dependency
29+
30+
Database is often used as the dependency for other services. This can easily be achieved.
31+
32+
```cgo
33+
kind: containers
34+
prefix: simplecontainer.io/v1
35+
meta:
36+
name: mysql
37+
group: mysql
38+
spec:
39+
image: "mysql"
40+
tag: "8.0"
41+
replicas: 1
42+
spread:
43+
spread: uniform
44+
envs:
45+
- MYSQL_ROOT_PASSWORD=(( .password ))
46+
- CONTAINER_NAME=(( .testing ))
47+
ports:
48+
- container: "3306"
49+
volumes:
50+
- type: bind
51+
hostPath: /tmp
52+
mountPoint: /tmp
53+
configurations:
54+
- group: mysql
55+
name: config
56+
resources:
57+
- group: mysql
58+
name: config
59+
key: my.cnf
60+
mountPoint: /etc/my.cnf
61+
- group: mysql
62+
name: config
63+
key: secret.config.file
64+
mountPoint: /etc/secret.cnf
65+
readiness:
66+
- name: "mysql"
67+
timeout: "60s"
68+
command: ["mysqladmin", "ping", "-h", "localhost", "-p(( .password ))"]
69+
configuration:
70+
username: "root"
71+
password: (( lookup "secret/mysql/password:password" | base64decode ))
72+
testing: (( lookup "runtime/container/configuration:name" ))
73+
testing2: (( lookup "runtime/container/configuration:name" ))
74+
secret: "secret"
75+
```
76+
77+
To create another container that depends on the database, definition:
78+
79+
```cgo
80+
kind: containers
81+
prefix: simplecontainer.io/v1
82+
meta:
83+
name: nginx
84+
group: nginx
85+
labels:
86+
test: testing2345
87+
spec:
88+
image: "nginx"
89+
tag: "1.23.3"
90+
replicas: 2
91+
dependencies:
92+
- prefix: "simplecontainer.io/v1"
93+
group: "mysql"
94+
name: "*"
95+
timeout: "30s"
96+
ports:
97+
- container: "80"
98+
- container: "443"
99+
resources:
100+
- group: nginx
101+
name: config
102+
key: nginx-configuration
103+
mountPoint: /etc/nginx/conf.d/default.conf
104+
configuration:
105+
username: "root"
106+
```
107+
108+
Dependencies relies on the group and name to match. Container/s that is/are referenced in the dependency needs to have it's
109+
own readiness completed successfully so that container will mark dependency as ready.
110+
111+
By default, as soon as the container is running readiness is successful.
112+
113+
Since container can have more replicas the wildcard `*` can be used in the name to wait for all container replicas.
114+
115+
Otherwise, it can be configured to match only specific instance using generated name eg. `mysql-mysql-1`. This follows naming convention.

docs/installation/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"label": "Running nodes",
3-
"position": 2,
3+
"position": 3,
44
"link": {
55
"type": "generated-index",
66
"description": "Learn how to deploy simplecontainer nodes whether single node or multiple nodes."

docs/installation/debugging.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 1
2+
sidebar_position: 5
33
---
44

55
# Debugging startup issues
@@ -14,13 +14,22 @@ The command above needs to run as the user who is not root and has correct acces
1414
## Docker socket access is not correctly configured
1515
Simplecontainer relies on the `/var/run/docker.sock` to communicate with the docker engine.
1616

17+
:::warning
18+
When changing ownership of the socket, security aspect needs to be taken into consideration.
19+
:::
20+
1721
### Option 1: Make user owner of the socket (Temporary solution)
1822
```cgo
1923
sudo chown $USER /var/run/docker.sock
2024
```
25+
This will change the ownership for the `docker.sock` for the current session and will allow communication to it.
26+
Reboot will clear permissions and this needs to be done again.
2127

2228
### Option 2: Add user to the group that has access to the /var/run/docker.sock (Permanent solution)
2329
```cgo
2430
GROUP_NAME=$(stat -c '%G' /var/run/docker.sock)
2531
sudo usermod -aG "$GROUP_NAME" "$USER"
26-
```
32+
```
33+
Assiging current user to the group, that has permissions `docker.sock`, will survive reboots and will enable access of the
34+
current user to the `docker.sock`. When starting simplecontainer node container - all group user has will be appended to the
35+
container itself and will solve all permission issues over socket.

docs/installation/prerequisites.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ In the background it relies on the `smrctl` and `smr` CLI and exposes to the use
3636

3737
To install smrmgr run the snippet below (it will install, under /usr/local/bin, both smr and smrctl).
3838

39-
:::warning
40-
These commands must be run as non-root user otherwise the deployment will fail.
41-
:::
42-
4339
```bash
4440
curl -sL https://smrmgr.simplecontainer.io -o smrmgr
4541
chmod +x smrmgr

docs/installation/running-cluster.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ This scenario assumes there are two nodes (virtual machines) connected over inte
2323

2424
First step is to start simplecontainer for the node 1.
2525

26+
:::warning
27+
The command smrmgr start must be run as non-root user otherwise the deployment will fail.
28+
:::
29+
2630
```bash
2731
smrmgr start -n smr-node-1 -d node-1.simplecontainer.io
2832
```
@@ -78,6 +82,10 @@ This will import context and fetch certificates from the node it got context fro
7882

7983
Start the simplecontainer for the node 2 and ask to join the cluster with client certificates from node 1.
8084

85+
:::warning
86+
The command smrmgr start must be run as non-root user otherwise the deployment will fail.
87+
:::
88+
8189
```cgo
8290
smrmgr start -n smr-node-2 -d node-2.simplecontainer.io -j -p https://node-1.simplecontainer.io:1443
8391
```

docs/installation/running-localhost.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ First check all prerequisites!
1414

1515
It is simple and easy.
1616

17+
:::warning
18+
The command smrmgr start must be run as non-root user otherwise the deployment will fail.
19+
:::
20+
1721
```cgo
1822
smrmgr start -n smr-node-1 -c "--port.control 127.0.0.1:1443 --port.overlay 127.0.0.1:9212"
1923
smrctl context import $(smr agent export --node smr-node-1) -y

docs/installation/running-single.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ First check prerequisites!
1717

1818
To run single node of simplecontainer on the machine run the snippet below.
1919

20+
:::warning
21+
The command smrmgr start must be run as non-root user otherwise the deployment will fail.
22+
:::
23+
2024
```bash text title="Starting simplecontainer node with control plane exposed on the smr.example.com"
2125
smrmgr start -n smr-node-1 -d node.simplecontainer.io
2226
```

docs/naming/_category_.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Naming",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Naming conventions and standards."
7+
}
8+
}

0 commit comments

Comments
 (0)