This is an old revision of the document!
Запустите с правами Administrator C:\cmder\cmder.exe bash cd test -d conf && rm -rf conf git clone http://val.bmstu.ru/unix/conf.git cd conf/virtualbox/ !!! 10 - это номер курса, вместо X укажите Ваш номер стенда, если не знаете его, спросите преподавателя !!! ./setup.sh X 10
# sh net_gate.sh # init 6
# sh net_server.sh # init 6
server# apt update
gate:~# ###git -C conf/ pull gate:~# sh conf/dhcp.sh
# cat /etc/resolv.conf
search corpX.un nameserver 192.168.X.10
# host kubeN
kube1:~# kubectl create ns my-keycloak-ns kube1:~# kubectl create secret tls keycloak-tls --key /tmp/keycloak.key --cert /tmp/keycloak.crt -n my-keycloak-ns
kube1:~/gitlab# sed -i -e 's/server.corpX/gitlab.corpX/' docker-compose.yml
...
privileged: true
...
- '22:22'
...
# - '/etc/gitlab:/etc/gitlab'
...
server# scp /opt/freeipa-data/etc/ipa/ca.crt kube1:/tmp/ kube1:~/gitlab# kubectl -n my-gitlab-ns create configmap ca-crt --from-file=/tmp/ca.crt
kube1:~/gitlab# kompose convert kube1:~/gitlab# cat vol1-persistentvolumeclaim.yaml
...
storage: 2000Mi
kube1:~/gitlab# cat gitlab-deployment.yaml
...
image: ...
# lifecycle:
# postStart:
# exec:
# command:
# - /bin/sh
# - -c
# - |
# mkdir -p /etc/gitlab/trusted-certs/
# cp /etc/gitlab/tmp/ca.crt /etc/gitlab/trusted-certs/ca.crt
# apt update && DEBIAN_FRONTEND=noninteractive apt install msmtp-mta bsd-mailx -y
# echo -e 'account default\nhost mail.corpX.un' > /etc/msmtprc
...
volumeMounts:
- name: gitlab-tls-volume
subPath: tls.crt
mountPath: /etc/gitlab/ssl/gitlab.corpX.un.crt
- name: gitlab-tls-volume
subPath: tls.key
mountPath: /etc/gitlab/ssl/gitlab.corpX.un.key
# - name: ca-crt-volume
# subPath: ca.crt
# mountPath: /etc/gitlab/tmp/ca.crt
...
hostname: gitlab
...
volumes:
- name: gitlab-tls-volume
secret:
secretName: gitlab-tls
# - name: ca-crt-volume
# configMap:
# name: ca-crt
...
kube1:~/gitlab# cat gitlab-service.yaml
... spec: loadBalancerIP: 192.168.X.65 type: LoadBalancer ...
kube1:~/gitlab# kubectl -n my-gitlab-ns apply -f vol1-persistentvolumeclaim.yaml,gitlab-service.yaml,gitlab-deployment.yaml kube1:~/gitlab# kubectl -n my-gitlab-ns logs pods/gitlab-<TAB> -f
kube1:~/webd-k8s# cat my-webd-deployment.yaml
...
image: httpd
lifecycle:
...
cd /usr/local/apache2/htdocs/
echo "<h1>Hello from htwebd on $(hostname) ver1.1</h1>" > index.html
kube1:~/webd-k8s# cp my-webd-deployment.yaml my-webd-deployment2.yaml kube1:~/webd-k8s# cp my-webd-service.yaml my-webd-service2.yaml ...
kube1:~/webd-k8s# kubectl delete ns my-ns kube1:~/webd-k8s# curl -fsSL https://val.bmstu.ru/unix/uni-webd-chart.tgz | tar xzvf - kube1:~/webd-k8s# less uni-webd-chart/values.yaml
... service: port: 80 ...
kube1:~/webd-k8s# mkdir -p apps/htwebd/ kube1:~/webd-k8s# cat apps/htwebd/values.yaml
hostname: htwebd replicaCount: 2 image: repository: httpd
kube1:~/webd-k8s# cat env.yaml
domain: corpX.un
kube1:~/webd-k8s# helm template my-htwebd uni-webd-chart/ -f apps/htwebd/values.yaml -f env.yaml
server# scp /opt/freeipa-data/etc/ipa/ca.crt kube1:/usr/local/share/ca-certificates/ server# ssh kube1 update-ca-certificates
kube1:~/webd-k8s# mkdir apps/ehwebd kube1:~/webd-k8s# cp uni-webd-chart/values.yaml apps/ehwebd/ ... kube1:~/webd-k8s# helm template my-ehwebd uni-webd-chart/ -f apps/ehwebd/values.yaml -f env.yaml
stages:
- lint
- build
- scan
- push
variables:
KANIKO_REGISTRY_MIRROR: "mirror.gcr.io"
Build:
stage: build
image:
name: gcr.io/kaniko-project/executor:v1.9.0-debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--insecure --skip-tls-verify
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}"
except:
- tags
tags:
- build
Push latest:
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
variables:
GIT_STRATEGY: none
stage: push
only:
- main
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane --insecure cp $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
tags:
- build
Push tag:
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
variables:
GIT_STRATEGY: none
stage: push
only:
- tags
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane --insecure cp $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
tags:
- build
semgrep:
stage: lint
image: semgrep/semgrep
script: semgrep --config=auto --error
variables:
SEMGREP_SRC_DIRECTORY: $CI_PROJECT_DIR
https_proxy: http://gate.isp.un:3128/
no_proxy: localhost,127.0.0.1,isp.un,corp1.un
except:
- tags
tags:
- build
trivy:
stage: scan
image:
name: ghcr.io/aquasecurity/trivy
entrypoint: [""]
variables:
#TRIVY_USERNAME: "$CI_REGISTRY_USER"
#TRIVY_PASSWORD: "$CI_REGISTRY_PASSWORD"
TRIVY_REGISTRY: "$CI_REGISTRY"
TRIVY_CACHE_DIR: ".trivycache/"
script:
- trivy image --exit-code 1 --severity HIGH --insecure $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
cache:
paths:
- ".trivycache/"
except:
- tags
tags:
- build
kube1:~/webd-k8s# mkdir apps/pywebd kube1:~/webd-k8s# cp uni-webd-chart/values.yaml apps/pywebd/ ... kube1:~/webd-k8s# helm template my-pywebd uni-webd-chart/ -f apps/pywebd/values.yaml -f env.yaml
root@my-ubuntu:/# apt install apache2 /etc/init.d/apache2 start tcpdump -nnieth0 -s0 -A port 80 root@my-ubuntu:/# snort -i eth0 -S HOME_NET=[0.0.0.0/0] -c /etc/snort/snort.conf # -A console
client1:~# time docker build -t gitlab.corpX.un:5000/student/gowebd:ver1.1 gowebd/ ... client1:~# time docker build -t gitlab.corpX.un:5000/student/gowebd:ver1.2 gowebd/
server# cp /opt/freeipa-data/etc/ipa/ca.crt kube1:/usr/local/share/ca-certificates/ update-ca-certificates systemctl reload docker