This commit is contained in:
Vladislav 2026-07-31 06:07:00 -04:00
parent 4c2c5a3ceb
commit 8f785f7a7d
2 changed files with 252 additions and 57 deletions

View File

@ -1,5 +1,20 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "80d363f7",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!pip install -r requirements.txt"
],
"display_name": ".venv"
},
{
"cell_type": "markdown",
"id": "750a3ea8",
@ -113,7 +128,26 @@
{
"cell_type": "code",
"execution_count": null,
"id": "63d3463e",
"id": "627c905d",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"%%bash\n",
"htpasswd -nbB 'user' $REGISTRY_PASS > /tmp/registry.htpasswd\n",
"kubectl -n container-registry create secret generic registry-basic-auth \\\n",
" --from-file=auth=/tmp/registry.htpasswd \\\n",
" --dry-run=client -o yaml | kubectl apply -f -\n"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "c3339daa",
"metadata": {
"vscode": {
"languageId": "shellscript"
@ -125,6 +159,21 @@
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "63d3463e",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!kubectl create secret docker-registry regcred -n kultmost --docker-server=$REGISTRY_HOST --docker-username='user' --docker-password=$REGISTRY_PASS --docker-email=\"$(git config --global --get user.email)\""
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
@ -295,6 +344,66 @@
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "06601f51",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!kubectl rollout restart StatefulSet/rabbitmq -n kultmost"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "14810826",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!kubectl get pod -n kultmost"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "d60a197b",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!kubectl delete deployments/ssh-reverse-tunnel -n kultmost"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "d6684726",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!kubectl delete StatefulSet/rabbitmq -n kultmost"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
@ -312,10 +421,60 @@
},
{
"cell_type": "markdown",
"id": "97d2a6d6",
"id": "92189739",
"metadata": {},
"source": [
"### k8s"
"### containers"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b3da4168",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"%%bash\n",
"docker pull busybox:1.36\n",
"docker pull rabbitmq:3.11-management\n",
"docker pull alpine:3.14\n",
"docker pull mongo:latest\n",
"docker tag mongo:latest $REGISTRY_HOST/mongo:latest\n",
"docker tag busybox:1.36 $REGISTRY_HOST/busybox:1.36\n",
"docker tag rabbitmq:3.11-management $REGISTRY_HOST/rabbitmq:3.11-management\n",
"docker tag alpine:3.14 $REGISTRY_HOST/alpine:3.14"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "62728f9d",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"%%bash\n",
"docker push $REGISTRY_HOST/mongo:latest\n",
"docker push $REGISTRY_HOST/busybox:1.36\n",
"docker push $REGISTRY_HOST/rabbitmq:3.11-management\n",
"docker push $REGISTRY_HOST/alpine:3.14"
],
"display_name": ".venv"
},
{
"cell_type": "markdown",
"id": "6b8282c4",
"metadata": {},
"source": [
"### tunnel"
]
},
{
@ -329,7 +488,21 @@
},
"outputs": [],
"source": [
"!docker build -t $REGISTRY_HOST/ssh-tunnel:2 tunnel/\n",
"!docker build -t $REGISTRY_HOST/ssh-tunnel:2 tunnel/"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "cf41b7b4",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!docker push $REGISTRY_HOST/ssh-tunnel:2"
],
"display_name": ".venv"
@ -364,6 +537,29 @@
],
"display_name": ".venv"
},
{
"cell_type": "markdown",
"id": "97d2a6d6",
"metadata": {},
"source": [
"### k8s"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a424dbb8",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!kubectl create namespace kultmost"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
@ -427,7 +623,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "291b15a8",
"metadata": {
"vscode": {
"languageId": "shellscript"
@ -435,7 +630,7 @@
},
"outputs": [],
"source": [
"!echo "
"!kubectl get pod -n kultmost"
],
"display_name": ".venv"
},
@ -508,7 +703,7 @@
},
"outputs": [],
"source": [
"#!rsync -avz ./static kultmost:/var/www/static/"
"!rsync -avz -ogp --chown=www-data:www-data ./static/ kultmost:/var/www/static/"
],
"display_name": ".venv"
},

View File

@ -430,54 +430,54 @@ stringData:
username: "root"
password: "$ROOT_PASS"
remote_host: "$REMOTE_HOST"
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: cron-day
namespace: kultmost
spec:
schedule: "0 0 * * *" # every day
jobTemplate:
spec:
template:
spec:
imagePullSecrets:
- name: regcred
restartPolicy: OnFailure
containers:
- name: cron-day
image: registry.spiritofweb.ru/alpine/curl
command: ["sh","-c","curl -sS http://kultmost-api.kultmost/cron/day -H \"Authorization: Bearer ${ATOKEN}\""]
env:
- name: ATOKEN
valueFrom:
secretKeyRef:
name: kultmost
key: ATOKEN
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: cron-five-minutes
namespace: kultmost
spec:
schedule: "*/5 * * * *" # every 5 min
jobTemplate:
spec:
template:
spec:
imagePullSecrets:
- name: regcred
restartPolicy: OnFailure
containers:
- name: cron-five
image: registry.spiritofweb.ru/alpine/curl
command: ["sh","-c","curl -sS http://kultmost-api.kultmost/cron/5 -H \"Authorization: Bearer ${ATOKEN}\""]
env:
- name: ATOKEN
valueFrom:
secretKeyRef:
name: kultmost
key: ATOKEN
# ---
# apiVersion: batch/v1
# kind: CronJob
# metadata:
# name: cron-day
# namespace: kultmost
# spec:
# schedule: "0 0 * * *" # every day
# jobTemplate:
# spec:
# template:
# spec:
# imagePullSecrets:
# - name: regcred
# restartPolicy: OnFailure
# containers:
# - name: cron-day
# image: registry.spiritofweb.ru/alpine/curl
# command: ["sh","-c","curl -sS http://kultmost-api.kultmost/cron/day -H \"Authorization: Bearer ${ATOKEN}\""]
# env:
# - name: ATOKEN
# valueFrom:
# secretKeyRef:
# name: kultmost
# key: ATOKEN
# ---
# apiVersion: batch/v1
# kind: CronJob
# metadata:
# name: cron-five-minutes
# namespace: kultmost
# spec:
# schedule: "*/5 * * * *" # every 5 min
# jobTemplate:
# spec:
# template:
# spec:
# imagePullSecrets:
# - name: regcred
# restartPolicy: OnFailure
# containers:
# - name: cron-five
# image: registry.spiritofweb.ru/alpine/curl
# command: ["sh","-c","curl -sS http://kultmost-api.kultmost/cron/5 -H \"Authorization: Bearer ${ATOKEN}\""]
# env:
# - name: ATOKEN
# valueFrom:
# secretKeyRef:
# name: kultmost
# key: ATOKEN