-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkube.sh
64 lines (56 loc) · 1.61 KB
/
kube.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# 设置变量
IMAGES="block1 compute1 controller database network rabbitmq-server"
NAMESPACE="default"
# alias kubectl="minikube kubectl"
# # 构建 Docker 镜像
for i in $IMAGES; do
echo "Building Docker image for ${i}.dockerfile..."
docker build -t "${i}-image" -f "${i}.dockerfile" .
done
# 创建 ConfigMap
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: common-env
data:
$(awk 'NF && $1!~/^#/ {split($0, a, "="); printf " %s: %s\n", a[1], a[2]}' common.env)
EOF
# for calio
# sudo mount bpffs -t bpf /sys/fs/bpf
# sudo mount --make-shared /sys/fs/bpf
# sudo mkdir -p /run/cilium/cgroupv2
# sudo mount -t cgroup2 none /run/cilium/cgroupv2
# sudo mount --make-shared /run/cilium/cgroupv2/
# kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/tigera-operator.yaml
# kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/custom-resources.yaml
# # 创建一个允许所有流量的 NetworkPolicy(仅供测试)
# kubectl apply -f - <<EOF
# apiVersion: networking.k8s.io/v1
# kind: NetworkPolicy
# metadata:
# name: allow-all
# namespace: default
# spec:
# podSelector: {}
# policyTypes:
# - Ingress
# - Egress
# ingress:
# - {}
# egress:
# - {}
# EOF
docker pull erichough/nfs-server:latest
docker pull memcached:latest
docker pull soarinferret/iptablesproxy
# 创建 Kubernetes 部署和服务
DEPLOYMENTS=$(ls kubes/*deployment.yaml)
SERVICES=$(ls kubes/*service.yaml)
for each in $DEPLOYMENTS; do
kubectl apply -f ${each}
done
for each in $SERVICES; do
kubectl apply -f ${each}
done