12 Commits

34 changed files with 400 additions and 362 deletions

View File

@ -1,2 +0,0 @@
rabbitmq_user: satanas
rabbitmq_password: satanas

View File

@ -1,9 +1,5 @@
[car]
satanas.local ansible_user=pi become=yes become_user=root
diabolo.local ansible_user=pi become=yes become_user=root
[microservice]
diabolo.local
[donkey]
satanas.local

View File

@ -93,3 +93,4 @@ dtoverlay=pi3-disable-bt
gpu_mem=256
dtoverlay=w1-gpio
enable_uart=1

View File

@ -481,3 +481,24 @@ fr_FR.UTF-8 UTF-8
# zh_TW.UTF-8 UTF-8
# zu_ZA ISO-8859-1
# zu_ZA.UTF-8 UTF-8
# agr_PE UTF-8
# az_IR UTF-8
# bho_NP UTF-8
# bi_VU UTF-8
# ca_ES@valencia UTF-8
# dsb_DE UTF-8
# el_GR@euro ISO-8859-7
# en_SC.UTF-8 UTF-8
# hif_FJ UTF-8
# kab_DZ UTF-8
# mai_NP UTF-8
# mfe_MU UTF-8
# miq_NI UTF-8
# mjw_IN UTF-8
# mnw_MM UTF-8
# sah_RU UTF-8
# shn_MM UTF-8
# sm_WS UTF-8
# to_TO UTF-8
# tpi_PG UTF-8
# yuw_PG UTF-8

View File

@ -1,35 +0,0 @@
- name: Add apt key
apt_key:
url: https://download.docker.com/linux/debian/gpg
- name: Add docker-ce repository
apt_repository:
repo: deb [arch={{ arch | default('armhf') }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable
state: present
filename: 'docker'
- meta: flush_handlers
- name: Install docker-ce
apt:
name:
- python3-pip
- docker-ce
- xfsprogs
state: present
- name: Set groups to pi user
user:
name: pi
groups: docker
- meta: flush_handlers
- name: Install ansible tool docker and docker-compose
pip:
name:
- docker-compose
executable: pip3

View File

@ -1,4 +0,0 @@
---
- include_tasks: docker.yml

View File

@ -1,13 +0,0 @@
---
donkey_username: pi
donkey_groupname: pi
donkey_home_dir: /home/{{ donkey_username }}
donkey_git_repo: https://github.com/cyrilix/donkey.git
donkey_git_branch: master
donkey_sources: "{{ donkey_home_dir }}/donkeycar"
donkey_virtualenv_dir: "{{ donkey_home_dir }}/venv"
donkey_data_dir: "{{ donkey_home_dir }}/data"

View File

@ -1,16 +0,0 @@
---
- name: Make data directory
file:
path: "{{ donkey_data_dir }}"
owner: "{{ donkey_username }}"
group: "{{ donkey_groupname }}"
state: directory
- name: Make tmpfs
mount:
path: "{{ donkey_data_dir }}"
src: tmpfs
fstype: tmpfs
opts: defaults
state: mounted

View File

@ -1,62 +0,0 @@
---
- include_tasks: data.yml
- name: Install dependencies
apt:
name:
- python3-setuptools-git
- virtualenv
- libopenjp2-7
- libtiff5
- libblas3
- liblapack3
- libatlas3-base
- libjpeg-dev
- libilmbase12
- libopenexr22
- libgstreamer1.0-0
- libavcodec57
- libavformat57
- libswscale4
- libgtk-3-0
- i2c-tools
- read-edid
- libsdl1.2debian
- libjasper1
- libqtgui4
- libqt4-test
- python-h5py
state: present
- name: Fetch git repository
become_user: "{{ donkey_username }}"
git:
repo: "{{ donkey_git_repo }}"
dest: "{{ donkey_sources }}"
version: "{{ donkey_git_branch }}"
ssh_opts: "-o StrictHostKeyChecking=no"
- name: Install donkey
become_user: "{{ donkey_username }}"
pip:
name: "{{ donkey_sources }}"
virtualenv_python: python3
virtualenv: "{{ donkey_virtualenv_dir }}"
editable: yes
#- name: Install dependencies
# become_user: "{{ donkey_username }}"
# pip:
# requirements: "{{ donkey_sources }}/requirements-pi.txt"
# virtualenv: "{{ donkey_virtualenv_dir }}"
# virtualenv_python: python3
- name: Load virtualenv at connection
template:
src: bash_custom
dest: "{{ donkey_home_dir }}/.bash_custom"
owner: "{{ donkey_username }}"
group: "{{ donkey_groupname }}"
mode: 0644

View File

@ -1,2 +0,0 @@
# Activate virtualenv
source {{ donkey_virtualenv_dir }}/bin/activate

View File

@ -1,3 +1,3 @@
---
k3s_version: v1.22.5%2Bk3s1
k3s_version: v1.25.3%2Bk3s1
k3s_url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s-{{ arch | default('armhf') }}

View File

@ -26,4 +26,4 @@ RestartSec=5s
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s server
ExecStart=/usr/local/bin/k3s server --disable traefik --disable-helm-controller

View File

@ -0,0 +1,20 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: robocar-pca9685-pwm
data:
############################
# STEERING PWM - PCA9685 #
############################
STEERING_PCA9685_LEFT_PWM: "995"
STEERING_PCA9685_RIGHT_PWM: "2017"
STEERING_PCA9685_CENTER_PWM: "1440"
###########################
# THROTTLE PWM - PCA9685 #
############################
THROTTLE_PCA9685_MIN_PWM: "994"
THROTTLE_PCA9685_MAX_PWM: "1975"
THROTTLE_PCA9685_ZERO_PWM: "1420"

View File

@ -103,10 +103,12 @@ spec:
spec:
containers:
- name: camera
image: docker.io/cyrilix/robocar-oak-camera
image: git.cyrilix.bzh/robocars/robocar-oak-camera
args:
- "--image-width=$(CAMERA_WIDTH)"
- "--image-height=$(CAMERA_HEIGHT)"
- "--objects-threshold=$(THRESHOLD_OBJECTS)"
- "--log=info"
securityContext:
runAsUser: 1234
privileged: true
@ -116,8 +118,10 @@ spec:
- name: dev
mountPath: /dev
env:
- name: MQTT_BROKER
- name: MQTT_BROKER_HOST
value: localhost # because use host network
- name: MQTT_BROKER_PORT
value: "30183"
- name: MQTT_USERNAME
valueFrom:
secretKeyRef:
@ -135,6 +139,16 @@ spec:
configMapKeyRef:
key: MQTT_TOPIC_CAMERA_OAK_COLOR
name: robocar
- name: MQTT_TOPIC_OBJECTS
valueFrom:
configMapKeyRef:
key: MQTT_TOPIC_OBJECTS
name: robocar
- name: THRESHOLD_OBJECTS
valueFrom:
configMapKeyRef:
key: OBJECTS_THRESHOLD
name: robocar-objects
- name: CAMERA_WIDTH
valueFrom:
configMapKeyRef:
@ -186,13 +200,13 @@ spec:
- "--mqtt-retain=false"
- "--throttle-channel=15"
- "--steering-channel=14"
- "--throttle-zero-pwm=$(THROTTLE_ZERO_PWM)"
- "--throttle-min-pwm=$(THROTTLE_MIN_PWM)"
- "--throttle-max-pwm=$(THROTTLE_MAX_PWM)"
- "--steering-left-pwm=$(STEERING_LEFT_PWM)"
- "--steering-right-pwm=$(STEERING_RIGHT_PWM)"
- "--steering-center-pwm=$(STEERING_CENTER_PWM)"
- "--pwm-freq=60"
- "--throttle-zero-pwm=$(THROTTLE_PCA9685_ZERO_PWM)"
- "--throttle-min-pwm=$(THROTTLE_PCA9685_MIN_PWM)"
- "--throttle-max-pwm=$(THROTTLE_PCA9685_MAX_PWM)"
- "--steering-left-pwm=$(STEERING_PCA9685_LEFT_PWM)"
- "--steering-right-pwm=$(STEERING_PCA9685_RIGHT_PWM)"
- "--steering-center-pwm=$(STEERING_PCA9685_CENTER_PWM)"
- "--pwm-freq=50"
- "--update-pwm-frequency=25"
- "--log=info"
securityContext:
@ -202,6 +216,9 @@ spec:
volumeMounts:
- mountPath: /dev/i2c-1
name: i2c
envFrom:
- configMapRef:
name: robocar-pca9685-pwm
env:
- name: MQTT_BROKER
valueFrom:
@ -232,36 +249,6 @@ spec:
name: robocar
- name: MQTT_QOS
value: "0"
- name: STEERING_LEFT_PWM
valueFrom:
configMapKeyRef:
name: robocar-steering-pwm
key: STEERING_LEFT_PWM
- name: STEERING_RIGHT_PWM
valueFrom:
configMapKeyRef:
name: robocar-steering-pwm
key: STEERING_RIGHT_PWM
- name: STEERING_CENTER_PWM
valueFrom:
configMapKeyRef:
name: robocar-steering-pwm
key: STEERING_CENTER_PWM
- name: THROTTLE_MIN_PWM
valueFrom:
configMapKeyRef:
name: robocar-throttle-pwm
key: THROTTLE_MIN_PWM
- name: THROTTLE_MAX_PWM
valueFrom:
configMapKeyRef:
name: robocar-throttle-pwm
key: THROTTLE_MAX_PWM
- name: THROTTLE_ZERO_PWM
valueFrom:
configMapKeyRef:
name: robocar-throttle-pwm
key: THROTTLE_ZERO_PWM
- name: TZ
value: "Europe/Paris"
volumes:

View File

@ -7,6 +7,7 @@ namespace: robocar
resources:
- ../common
- deployments.yaml
- configmap.yaml
images:
- name: docker.io/cyrilix/robocar-camera
@ -15,5 +16,5 @@ images:
- name: docker.io/cyrilix/robocar-pca9685
newTag: v0.6.4
- name: docker.io/cyrilix/robocar-oak-camera
newTag: v0.1.0
- name: git.cyrilix.bzh/robocars/robocar-oak-camera
newTag: v0.2.0-28-g7ebd909

View File

@ -4,13 +4,16 @@ metadata:
name: robocar
data:
# Broker configuration
MQTT_BROKER_HOST: mqtt.robocar.svc.cluster.local
MQTT_BROKER: "tcp://mqtt.robocar.svc.cluster.local:1883"
MQTT_BROKER_HOST: nats-server.nats.svc.cluster.local
#MQTT_BROKER: "tcp://mqtt.robocar.svc.cluster.local:1883"
MQTT_BROKER: "tcp://nats-server.nats.svc.cluster.local:1883"
# Camera
MQTT_TOPIC_CAMERA: car/satanas/part/camera/color
MQTT_TOPIC_CAMERA_OAK_COLOR: car/satanas/part/camera/color
# Objects detection
MQTT_TOPIC_OBJECTS: car/satanas/part/objects
# Radio command
MQTT_TOPIC_RC_THROTTLE: car/satanas/part/rc/throttle
@ -31,6 +34,9 @@ data:
# Records topic
MQTT_TOPIC_RECORDS: car/satanas/part/records
# Feedbacks
MQTT_TOPIC_THROTTLE_FEEDBACK: car/satanas/part/feedback/throttle
---
apiVersion: v1
kind: ConfigMap
@ -40,13 +46,21 @@ data:
############
# Throttle #
############
# Min value to start is 0.12
# Good value for manual: 0.15
#THROTTLE_MIN: "0.15"
#THROTTLE_MAX: "0.15"
THROTTLE_MIN: "0.19"
THROTTLE_MAX: "0.19"
## For manual driving
#####################
# THROTTLE_MIN: "0.10"
# THROTTLE_MAX: "0.12"
## Secure auto-pilot
####################
THROTTLE_MIN: "0.10"
THROTTLE_MAX: "0.12"
## Speed auto-pilot
###################
# THROTTLE_MIN: "0.11"
# THROTTLE_MAX: "0.13"
---
@ -58,9 +72,17 @@ data:
################
# STEERING PWM #
################
STEERING_LEFT_PWM: "1002"
STEERING_LEFT_PWM: "1000"
STEERING_RIGHT_PWM: "1985"
STEERING_CENTER_PWM: "1491"
STEERING_CENTER_PWM: "1492"
############################
# STEERING PWM - SECOND RC #
############################
STEERING_SECONDARY_LEFT_PWM: "1119"
STEERING_SECONDARY_RIGHT_PWM: "2141"
STEERING_SECONDARY_CENTER_PWM: "1641"
---
apiVersion: v1
kind: ConfigMap
@ -70,12 +92,17 @@ data:
################
# THROTTLE PWM #
################
#THROTTLE_MIN_PWM: "1092"
#THROTTLE_MAX_PWM: "1986"
#THROTTLE_ZERO_PWM: "1583"
THROTTLE_MIN_PWM: "960"
THROTTLE_MAX_PWM: "1949"
THROTTLE_ZERO_PWM: "1452"
THROTTLE_MIN_PWM: "994"
THROTTLE_MAX_PWM: "1979"
THROTTLE_ZERO_PWM: "1484"
###########################
# THROTTLE PWM - SECOND RC #
############################
THROTTLE_SECONDARY_MIN_PWM: "994"
THROTTLE_SECONDARY_MAX_PWM: "1975"
THROTTLE_SECONDARY_ZERO_PWM: "1506"
---
apiVersion: v1
kind: ConfigMap
@ -101,7 +128,6 @@ metadata:
data:
# model to use for steering
MODEL_STEERING: model_categorical_160x120h0_edgetpu.tflite
#MODEL_STEERING: model_categorical_160x120h0_edgetpu.tflite
#MODEL_STEERING: model_linear_160x120h40_edgetpu.tflite
@ -115,7 +141,6 @@ data:
MODEL_IMAGE_WIDTH: "160"
MODEL_IMAGE_HEIGHT: "120"
HORIZON: "20"
---
apiVersion: v1
kind: ConfigMap
@ -123,3 +148,62 @@ metadata:
name: robocar-road
data:
HORIZON: "20"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: steering
data:
grid.json: |
{
"steering_steps": [ -1, -0.66, -0.33, 0, 0.33, 0.66, 1],
"distance_steps": [ 0, 0.3, 0.4, 0.5, 0.8, 1],
"data": [
[ 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0],
[ 0, 0, 0.25, -0.25, 0, 0],
[ 0, 0.25, 0.5, -0.5, -0.25, 0],
[ 0.25, 0.5, 1, -1, -0.5, -0.25]
]
}
"omf.json": |
{
"steering_steps":[-1, -0.66, -0.33, 0, 0.33, 0.66, 1],
"distance_steps": [0, 0.2, 0.4, 0.6, 0.8, 1],
"data": [
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0.25, 0, 0, -0.25, 0],
[0.5, 0.25, 0, 0, -0.5, -0.25]
]
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: robocar-objects
data:
OBJECTS_THRESHOLD: "0.2"
# To delete?
thresholds.json: |
{
"threshold_steps": [ 0.07, 0.08, 0.09, 0.1, 0.125, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ],
"min_valid": 500,
"data": [ 8700, 4800, 3500, 2550, 1850, 1387, 992, 840, 750, 700, 655, 620, 590, 570, 553, 549, 548 ]
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: throttle
data:
brake.json: |
{
"delta_steps": [ 0.05, 0.3, 0.5 ],
"data": [ -0.1, -0.5, -1.0 ]
}

View File

@ -28,17 +28,31 @@ spec:
- "--steering-left-pwm=$(STEERING_LEFT_PWM)"
- "--steering-right-pwm=$(STEERING_RIGHT_PWM)"
- "--steering-center-pwm=$(STEERING_CENTER_PWM)"
- "--throttle-zero-pwm=$(THROTTLE_ZERO_PWM)"
- "--steering-secondary-left-pwm=$(STEERING_SECONDARY_LEFT_PWM)"
- "--steering-secondary-right-pwm=$(STEERING_SECONDARY_RIGHT_PWM)"
- "--steering-secondary-center-pwm=$(STEERING_SECONDARY_CENTER_PWM)"
- "--throttle-min-pwm=$(THROTTLE_MIN_PWM)"
- "--throttle-max-pwm=$(THROTTLE_MAX_PWM)"
- "--throttle-center-pwm=$(THROTTLE_ZERO_PWM)"
- "--throttle-secondary-min-pwm=$(THROTTLE_SECONDARY_MIN_PWM)"
- "--throttle-secondary-max-pwm=$(THROTTLE_SECONDARY_MAX_PWM)"
- "--throttle-secondary-center-pwm=$(THROTTLE_SECONDARY_ZERO_PWM)"
- '--throttle-feedback-config=/etc/robocar/thresholds.json'
- "-log=info"
volumeMounts:
- mountPath: "/dev/ttyAMA0"
name: serial
- mountPath: "/etc/robocar"
name: robocar
securityContext:
privileged: true
runAsUser: 1234
runAsGroup: 20 # Set 20/dialout group to access to serial device
envFrom:
- configMapRef:
name: robocar-throttle-pwm
- configMapRef:
name: robocar-steering-pwm
env:
- name: MQTT_BROKER
valueFrom:
@ -77,39 +91,13 @@ spec:
configMapKeyRef:
key: MQTT_TOPIC_RC_SWITCH_RECORD
name: robocar
- name: MQTT_TOPIC_THROTTLE_FEEDBACK
valueFrom:
configMapKeyRef:
name: robocar
key: MQTT_TOPIC_THROTTLE_FEEDBACK
- name: MQTT_QOS
value: "0"
- name: STEERING_LEFT_PWM
valueFrom:
configMapKeyRef:
name: robocar-steering-pwm
key: STEERING_LEFT_PWM
- name: STEERING_RIGHT_PWM
valueFrom:
configMapKeyRef:
name: robocar-steering-pwm
key: STEERING_RIGHT_PWM
- name: STEERING_CENTER_PWM
valueFrom:
configMapKeyRef:
name: robocar-steering-pwm
key: STEERING_CENTER_PWM
- name: THROTTLE_MIN_PWM
valueFrom:
configMapKeyRef:
name: robocar-throttle-pwm
key: THROTTLE_MIN_PWM
- name: THROTTLE_MAX_PWM
valueFrom:
configMapKeyRef:
name: robocar-throttle-pwm
key: THROTTLE_MAX_PWM
- name: THROTTLE_ZERO_PWM
valueFrom:
configMapKeyRef:
name: robocar-throttle-pwm
key: THROTTLE_ZERO_PWM
- name: TZ
value: "Europe/Paris"
volumes:
@ -117,6 +105,9 @@ spec:
hostPath:
path: /dev/ttyAMA0
type: CharDevice
- name: robocar
configMap:
name: robocar-objects
---
apiVersion: apps/v1
@ -328,6 +319,13 @@ spec:
image: docker.io/cyrilix/robocar-steering
args:
- "-mqtt-retain=false"
- "--image-width=$(IMAGE_WIDTH)"
- "--image-height=$(IMAGE_HEIGHT)"
- "--enable-objects-correction=false"
- "--enable-objects-correction-user=false"
- "--grid-map-config=/etc/robocar/grid.json"
- "--objects-move-factors-config=/etc/robocar/omf.json"
- "--delta-middle=0.1"
- "-log=info"
securityContext:
runAsUser: 1234
@ -370,10 +368,32 @@ spec:
configMapKeyRef:
key: MQTT_TOPIC_RC_DRIVE_MODE
name: robocar
- name: MQTT_TOPIC_OBJECTS
valueFrom:
configMapKeyRef:
key: MQTT_TOPIC_OBJECTS
name: robocar
- name: MQTT_QOS
value: "0"
- name: IMAGE_WIDTH
valueFrom:
configMapKeyRef:
key: CAMERA_WIDTH
name: robocar-camera
- name: IMAGE_HEIGHT
valueFrom:
configMapKeyRef:
key: CAMERA_HEIGHT
name: robocar-camera
- name: TZ
value: "Europe/Paris"
volumeMounts:
- mountPath: /etc/robocar
name: robocar-configs
volumes:
- name: robocar-configs
configMap:
name: steering
---
apiVersion: apps/v1
kind: Deployment
@ -398,8 +418,10 @@ spec:
- name: throttle
image: docker.io/cyrilix/robocar-throttle
args:
- "-mqtt-retain=false"
- "-log=info"
- "--mqtt-retain=false"
- "--enable-brake-feature=true"
- "--brake-configuration=/etc/robocar/brake.json"
- "--log=info"
securityContext:
runAsUser: 1234
runAsGroup: 1234
@ -436,6 +458,16 @@ spec:
configMapKeyRef:
key: MQTT_TOPIC_RC_DRIVE_MODE
name: robocar
- name: MQTT_TOPIC_THROTTLE_FEEDBACK
valueFrom:
configMapKeyRef:
name: robocar
key: MQTT_TOPIC_THROTTLE_FEEDBACK
- name: MQTT_TOPIC_STEERING
valueFrom:
configMapKeyRef:
key: MQTT_TOPIC_STEERING
name: robocar
- name: THROTTLE_MIN
valueFrom:
configMapKeyRef:
@ -450,6 +482,13 @@ spec:
value: "0"
- name: TZ
value: "Europe/Paris"
volumeMounts:
- mountPath: /etc/robocar
name: throttle-config
volumes:
- name: throttle-config
configMap:
name: throttle
---
apiVersion: apps/v1
kind: Deployment

View File

@ -1,13 +0,0 @@
---
apiVersion: v1
kind: Endpoints
metadata:
name: mqtt
labels:
app: mqtt
subsets:
- addresses:
- ip: 192.168.2.221
# - ip: 192.168.217.19
ports:
- port: 1883

View File

@ -3,24 +3,23 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- deployments.yaml
- endpoints.yaml
- services.yaml
- configmap.yaml
images:
- name: docker.io/cyrilix/robocar-arduino
newTag: v0.8.0
newTag: v0.9.0
- name: docker.io/cyrilix/robocar-led
newTag: v0.5.1
- name: docker.io/cyrilix/robocar-steering-tflite-edgetpu
#newTag: v0.5.0
newTag: v0.5.0-1-gbc90193
newTag: v0.5.3
- name: docker.io/cyrilix/robocar-throttle
newTag: v0.5.0
newTag: v0.6.0
- name: docker.io/cyrilix/robocar-record
newTag: v0.5.1
@ -29,7 +28,7 @@ images:
newTag: v0.2.1
- name: docker.io/cyrilix/robocar-steering
newTag: v0.5.1
newTag: v0.6.0
- name: docker.io/cyrilix/robocar-road
newTag: v0.2.0

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: robocar

View File

@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: mqtt-credentials
namespace: robocar
stringData:
MQTT_USERNAME: satanas
MQTT_PASSWORD: satanas

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nats
data:
standalone.conf: |
server_name: nats
http: 0.0.0.0:8222
jetstream {
store_dir: /data/datastore
}
mqtt {
listen: 0.0.0.0:1883
}
authorization: {
user: satanas,
password: satanas
}

View File

@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: nats
resources:
- namespace.yaml
- serviceaccount.yaml
- configmaps.yaml
- statefulset.yaml
- services.yaml

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: nats

View File

@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: nats-server
automountServiceAccountToken: false

View File

@ -0,0 +1,41 @@
apiVersion: v1
kind: Service
metadata:
name: nats-server-ext
spec:
type: NodePort
ports:
- port: 4222
name: tcp-nats-client
targetPort: tcp-nats-client
nodePort: 30422
- name: http-monitoring
port: 8222
targetPort: http-monitoring
nodePort: 30822
- name: tcp-mqtt
port: 1883
targetPort: tcp-mqtt
nodePort: 30183
selector:
appli: nats-server
---
apiVersion: v1
kind: Service
metadata:
name: nats-server
spec:
type: ClusterIP
ports:
- port: 4222
name: tcp-nats-client
targetPort: tcp-nats-client
- name: http-monitoring
port: 8222
targetPort: http-monitoring
- name: tcp-mqtt
port: 1883
targetPort: tcp-mqtt
selector:
appli: nats-server

View File

@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nats-server
annotations:
reloader.stakater.com/auto: "true"
spec:
selector:
matchLabels:
appli: nats-server
serviceName: nats
replicas: 1
revisionHistoryLimit: 0
template:
metadata:
name: nats-server
labels:
appli: nats-server
spec:
serviceAccountName: nats-server
containers:
- name: nats-server
image: docker.io/library/nats:latest
args:
- --http_port=8222
- --config=/etc/nats/standalone.conf
ports:
- containerPort: 4222
name: tcp-nats-client
- name: http-monitoring
containerPort: 8222
- name: tcp-mqtt
containerPort: 1883
volumeMounts:
- mountPath: /etc/nats
name: nats-config
- name: nats-data
mountPath: /data
securityContext:
runAsUser: 1234
runAsGroup: 1234
fsGroup: 1234
fsGroupChangePolicy: Always
volumes:
- name: nats-config
configMap:
name: nats
volumeClaimTemplates:
- metadata:
name: nats-data
spec:
resources:
requests:
storage: 1Gi
storageClassName: local-path
accessModes:
- ReadWriteOnce

View File

@ -3,6 +3,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- https://github.com/stakater/Reloader/deployments/kubernetes
namespace: reloader

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: reloader

View File

@ -1,4 +0,0 @@
---
version: 3.6.6
threads: 4

View File

@ -1,52 +0,0 @@
---
- name: "Install python {{version}} runtime & build dependencies"
become: yes
apt: name={{item}}
with_items:
- build-essential
- tk-dev
- libncurses5-dev
- libncursesw5-dev
- libreadline6-dev
- libdb5.3-dev
- libgdbm-dev
- libsqlite3-dev
- libssl-dev
- libbz2-dev
- libexpat1-dev
- liblzma-dev
- libffi-dev
- uuid-dev
- zlib1g-dev
- name: "Download python{{version}}"
get_url:
url: "https://www.python.org/ftp/python/{{version}}/Python-{{version}}.tar.xz"
dest: "/tmp/Python-{{version}}.tar.xz"
- name: "Unarchive python{{version}}"
unarchive:
src: "/tmp/Python-{{version}}.tar.xz"
dest: "/tmp/"
copy: no
creates: "/tmp/Python-{{version}}"
- name: "configure python{{version}} build"
command: ./configure --prefix=/opt/python-{{version}} --enable-optimizations
args:
chdir: "/tmp/Python-{{version}}"
creates: "/tmp/Python-{{version}}/Makefile"
- name: "build python{{version}}"
# not using make module to be able to use -j and creates option to fully skip step
command: make -j{{threads}}
args:
chdir: "/tmp/Python-{{version}}"
creates: "/tmp/Python-{{version}}/python"
- name: "install python{{version}}"
become: yes
make:
chdir: "/tmp/Python-{{version}}"
target: altinstall

View File

@ -1,11 +0,0 @@
---
- name: expand filesystem
shell: resize2fs /dev/mmcblk0p2
notify:
- reboot
- name: restart rabbitmq
service:
name: rabbitmq-server
start: restarted

View File

@ -1,35 +0,0 @@
---
- name: Install ansible dependencies
apt:
name: "python3-requests"
state: present
- name: Install rabbitmq package
apt:
name: rabbitmq-server
state: present
with_items:
- rabbitmq-server
- python3-requests
- name: Enables rabbitmq plugins
rabbitmq_plugin:
names: rabbitmq_management,rabbitmq_mqtt
state: enabled
- name: Add rabbitmq user
rabbitmq_user:
user: "{{ rabbitmq_user }}"
password: "{{ rabbitmq_password }}"
vhost: /
configure_priv: .*
read_priv: .*
write_priv: .*
tags: administrator
state: present
- name: Create exchange
rabbitmq_exchange:
name: car
type: topic
vhost: "/"

View File

@ -8,13 +8,5 @@
- hosts: microservice
become: yes
roles:
- { role: rabbitmq, tags: [rabbitmq] }
- { role: k3s, tags: [k3s] }
- { role: microservices, tags: [microservices, ms] }
- hosts: donkey
become: yes
roles:
- { role: python, tags: [python]}
- { role: donkey, tags: [donkey] }