-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from GMH233/dev
完成验收答辩
- Loading branch information
Showing
119 changed files
with
13,673 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ "main", "dev"] | ||
pull_request: | ||
branches: [ "main", "dev" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.22.x' | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v ./... |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 使用官方的 Golang 镜像作为基础镜像 | ||
FROM golang:bullseye AS builder | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 复制源代码到工作目录 | ||
COPY . . | ||
|
||
WORKDIR /app/cmd/envoy | ||
# 编译 Go 程序 | ||
RUN go build -o /envoy | ||
|
||
# 使用官方的 Debian 镜像作为基础镜像 | ||
FROM debian:bullseye | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 从构建阶段复制编译后的 Go 程序 | ||
COPY --from=builder /envoy . | ||
|
||
# 创建用户和组,并设置 UID 为 1337 | ||
RUN groupadd -g 1337 envoy_proxy_group && useradd -u 1337 -g envoy_proxy_group -m envoy_proxy | ||
|
||
# 更改文件所有者为新创建的用户和组 | ||
RUN chown -R envoy_proxy:envoy_proxy_group /app | ||
|
||
# 切换到非特权用户 | ||
USER envoy_proxy | ||
|
||
# 设置默认命令 | ||
CMD ["/app/envoy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"minikubernetes/pkg/microservice/envoy" | ||
) | ||
|
||
func main() { | ||
e, err := envoy.NewEnvoy("10.119.12.123") | ||
if err != nil { | ||
log.Fatalf("Failed to create envoy: %v", err) | ||
} | ||
e.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 使用官方的 Golang 镜像作为基础镜像 | ||
FROM golang:bullseye AS builder | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 复制源代码到工作目录 | ||
COPY . . | ||
|
||
WORKDIR /app/cmd/envoyinit | ||
# 编译 Go 程序 | ||
RUN go build -o /envoy-init | ||
|
||
# 使用官方的 Debian 镜像作为基础镜像 | ||
FROM debian:bullseye | ||
|
||
USER root | ||
|
||
# 安装 iptables | ||
RUN apt-get update && apt-get install -y iptables && rm -rf /var/lib/apt/lists/* | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 从构建阶段复制编译后的 Go 程序 | ||
COPY --from=builder /envoy-init . | ||
|
||
## 创建用户和组,并设置 UID 为 1337 | ||
#RUN groupadd -g 1337 envoy_proxy_group && useradd -u 1337 -g envoy_proxy_group -m envoy_proxy | ||
# | ||
## 更改文件所有者为新创建的用户和组 | ||
#RUN chown -R envoy_proxy:envoy_proxy_group /app | ||
# | ||
## 切换到非特权用户 | ||
#USER envoy_proxy | ||
|
||
# 设置默认命令 | ||
CMD ["/app/envoy-init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
envoyinit "minikubernetes/pkg/microservice/envoy/init" | ||
) | ||
|
||
func main() { | ||
e, err := envoyinit.NewEnvoyInit() | ||
if err != nil { | ||
log.Fatalf("Failed to create envoy: %v", err) | ||
} | ||
err = e.Init() | ||
if err != nil { | ||
log.Fatalf("Failed to init envoy: %v", err) | ||
} | ||
log.Println("Envoy init success.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
import "minikubernetes/pkg/kubeapiserver/app" | ||
|
||
/* This is the starting interface of apiserver in main */ | ||
|
||
func main() { | ||
kubeApiServer, err := app.NewKubeApiServer() | ||
if err != nil { | ||
return | ||
} | ||
kubeApiServer.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package main | ||
|
||
import ( | ||
"minikubernetes/pkg/controller" | ||
) | ||
|
||
func main() { | ||
cm := controller.NewControllerManager("192.168.1.10") | ||
cm.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "minikubernetes/pkg/kubectl/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: v1 | ||
kind: DNS | ||
metadata: | ||
name: nginx-dns | ||
spec: | ||
rules: | ||
- host: myservice.com | ||
paths: | ||
- path: /service1 | ||
backend: | ||
service: | ||
name: nginx-service | ||
port: 801 | ||
- path: /service2 | ||
backend: | ||
service: | ||
name: nginx-service-2 | ||
port: 802 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
kind: HorizontalPodAutoscaler | ||
apiVersion: v1 | ||
metadata: | ||
name: test-hpa | ||
spec: | ||
scaleTargetRef: | ||
kind: ReplicaSet | ||
name: nginx-replicaset | ||
namespace: default | ||
minReplicas: 1 | ||
maxReplicas: 3 | ||
scaleWindowSeconds: 20 | ||
metrics: | ||
- name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: 50 | ||
upperThreshold: 80 | ||
lowerThreshold: 20 | ||
behavior: | ||
scaleUp: | ||
type: Pods | ||
value: 1 | ||
periodSeconds: 60 | ||
scaleDown: | ||
type: Pods | ||
value: 1 | ||
periodSeconds: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
kind: HorizontalPodAutoscaler | ||
apiVersion: v1 | ||
metadata: | ||
name: test-hpa | ||
spec: | ||
scaleTargetRef: | ||
kind: ReplicaSet | ||
name: nginx-replicaset | ||
namespace: default | ||
minReplicas: 1 | ||
maxReplicas: 3 | ||
scaleWindowSeconds: 20 | ||
metrics: | ||
- name: memory | ||
target: | ||
type: AverageValue | ||
AverageValue: 100 | ||
behavior: | ||
scaleUp: | ||
type: Pods | ||
value: 1 | ||
periodSeconds: 60 | ||
scaleDown: | ||
type: Pods | ||
value: 1 | ||
periodSeconds: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
kind: Pod | ||
apiVersion: v1 | ||
metadata: | ||
name: nginx-pod-1 | ||
namespace: default | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: container | ||
image: python:latest | ||
ports: | ||
- containerPort: 1024 | ||
protocol: tcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
kind: ReplicaSet | ||
apiVersion: v1 | ||
metadata: | ||
name: nginx-replicaset | ||
namespace: default | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
name: nginx-pod | ||
namespace: default | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: container | ||
image: python:latest | ||
ports: | ||
- containerPort: 1024 | ||
protocol: tcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: v1 | ||
kind: RollingUpdate | ||
metadata: | ||
name: my-ru | ||
spec: | ||
serviceRef: reviews | ||
port: 9080 | ||
minimumAlive: 1 | ||
interval: 20 | ||
newPodSpec: | ||
containers: | ||
- name: reviews | ||
image: istio/examples-bookinfo-reviews-v3:1.19.1 | ||
ports: | ||
- containerPort: 9080 | ||
protocol: tcp | ||
- name: envoy-proxy | ||
image: sjtuzc/envoy:1.1 | ||
securityContext: | ||
runAsUser: 1337 | ||
initContainers: | ||
- name: proxy-init | ||
image: sjtuzc/envoy-init:latest | ||
securityContext: | ||
privileged: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: nginx-service | ||
|
||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 801 | ||
targetPort: 1024 | ||
nodePort: 30081 | ||
selector: | ||
app: nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Subset | ||
metadata: | ||
name: nginx-v1 | ||
namespace: default | ||
spec: | ||
pods: | ||
- nginx-pod-1 | ||
- nginx-pod-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: VirtualService | ||
metadata: | ||
name: nginx-vs | ||
namespace: default | ||
spec: | ||
serviceRef: nginx-service | ||
port: 802 | ||
subsets: | ||
- name: nginx-v1 | ||
weight: 1 |
Oops, something went wrong.