-
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.
- Loading branch information
Showing
9 changed files
with
101 additions
and
2 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,2 @@ | ||
|
||
*.sum |
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,5 @@ | ||
FROM scratch | ||
COPY ./dev /usr/local/bin/dev | ||
WORKDIR /usr/local/bin/ | ||
EXPOSE 80 | ||
CMD [ "dev" ] |
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,5 @@ | ||
all:build | ||
|
||
build: | ||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o dev . | ||
docker build -t gogateway/dev . |
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 |
---|---|---|
@@ -1,2 +1,28 @@ | ||
# dev | ||
一个简单的k8s-ingress | ||
# dev-ingress | ||
一个简单的k8s-ingress,开发代理神器 | ||
# 背景 | ||
K8S集群内部的服务在外部不能访问,如需外部访问需要ingress做代理。官方有nginx-ingress,安装配置比较麻烦,想弄个简单的,只需要提交个表单就能配置完成的那种。 | ||
|
||
想到之前写的一个开发联调神器dev-proxy可以做简单的代理使用,配置方便。把她部署在k8s集群里是否就能直接配置服务了。。想到就做。。。。 | ||
|
||
k8s的nodePort端口(默认为30000-32767)我使用下面的方式修改的端口,可能有不同改法,自行百度 | ||
``` | ||
vim /etc/kubernetes/manifests/kube-apiserver.yaml | ||
--service-node-port-range=80-65535 | ||
``` | ||
# 部署到k8s集群 | ||
``` | ||
kubectl apply -f k8s.yaml | ||
kubectl apply -f dev-service.yaml | ||
``` | ||
# 服务配置 | ||
|
||
- 访问集群中任意节点 http://ip/admin即可打开配置页面 | ||
- 如下图,有 kong-kong-proxy 服务在运行 | ||
``` | ||
# 查看集群中的服务 | ||
kubectl get svc -o wide | ||
``` | ||
![image](doc/svc.jpg) | ||
- 配置填写:kong=>kong-kong-proxy(后缀=>k8s的服务名,即可访问) | ||
- 访问 http://ip/kong 即可看到效果 |
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,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: dev | ||
labels: | ||
app: dev | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: dev | ||
template: | ||
metadata: | ||
labels: | ||
app: dev | ||
spec: | ||
containers: | ||
- name: dev | ||
image: gogateway/dev:latest | ||
ports: | ||
- containerPort: 80 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
module github.com/gogateway/dev | ||
|
||
go 1.14 | ||
|
||
require github.com/go-proxy/dev v0.1.1 |
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 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"github.com/go-proxy/dev" | ||
"log" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
func main() { | ||
port := os.Getenv("port") | ||
if port == "" { | ||
p := flag.String("port", "80", "port default 80") | ||
port = *p | ||
} | ||
dev := dev.NewProxy() | ||
log.Println("start port :" + port) | ||
err := http.ListenAndServe(":"+port, dev) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
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,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: dev-service | ||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 80 | ||
targetPort: 80 | ||
nodePort: 80 | ||
selector: | ||
app: dev |