搭建Google OnlineBoutique流程

1. 资料准备:

2. 环境准备:

2.1 Docker engine:

Document:https://docs.docker.com/engine/install/ubuntu/

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

2.2 kubectl:

1
2
3
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client --output=yaml

2.3 skaffold (2.0+):

https://skaffold.dev/docs/install/

1
2
3
4
# For Linux x86_64 (amd64)
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
skaffold version

2.4 minikube:

https://minikube.sigs.k8s.io/docs/start/

1
2
3
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube version

2.5 kind:

https://kind.sigs.k8s.io/docs/user/quick-start

1
2
3
4
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
kind --version

3. 创建集群:

注意,创建集群时,务必连接VPN,否则会超时. 代理的配置请见笔记:Ubuntu下配置代理

minikube start --docker-env http_proxy=http://127.0.0.1:7890 --docker-env https_proxy=http://127.0.0.1:7890 --docker-env no_proxy=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24

机器配置

4 CPUs

4.0 GiB memory

32 GB disk space

1
2
3
4
# 如果使用代理 (只有第一次拉镜像需要vpn)
minikube start --docker-env http_proxy=192.168.8.2:7890 --docker-env https_proxy=192.168.8.2:7890 --docker-env no_proxy=localhost,127.0.0.1,10.96.0.0/12,192.168.0.1/16,192.168.49.2 --cpus=4 --memory 4096 --disk-size 32g

minikube start --cpus=4 --memory 4096 --disk-size 32g

查看是否连上了控制面板

1
kubectl get nodes

运行集群

1
2
3
4
5
skaffold run
# 这一步仍然需要VPN
export http_proxy=192.168.8.2:7890
export https_proxy=192.168.8.2:7890
export no_proxy="localhost,127.0.0.1,10.96.0.0/12,192.168.0.1/16,192.168.49.2"

获取所有pods

1
kubectl get pods

清理

1
skaffold delete

4. 收集指标

安装Prometheus

1
2
3
4
5
6
sudo snap install helm --classic
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/prometheus
kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-np
# 开放prometheus的端口,可供外部访问, 并自动打开浏览器访问
minikube service prometheus-server-np

安装Grafana

1
2
3
4
5
6
7
helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana grafana/grafana
kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-np
# 这一行打印账号“admin”的密码,需要记住!
kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
# 开放Grafana的端口,可供外部访问, 并自动打开浏览器访问
minikube service grafana-np

需要在Grafana中配置来自Prometheus的datasource,就可以创建pane进行可视化,并且导出数据了。但是这里仍然不包含fault injection的部分,需要找一个合适的故障注入工具。


搭建Google OnlineBoutique流程
https://www.torch-fan.site/2022/12/26/搭建Google-OnlineBoutique流程/
作者
Torch-Fan
发布于
2022年12月26日
更新于
2023年2月8日
许可协议