Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
8412efbc
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8412efbc
编写于
2月 15, 2021
作者:
M
Medya Gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add addons
上级
5dfc3048
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
110 addition
and
25 deletion
+110
-25
deploy/addons/auto-pause/auto-pause.service
deploy/addons/auto-pause/auto-pause.service
+9
-0
deploy/addons/auto-pause/auto-pause.yaml.tmpl
deploy/addons/auto-pause/auto-pause.yaml.tmpl
+3
-9
deploy/addons/auto-pause/haproxy.cfg
deploy/addons/auto-pause/haproxy.cfg
+6
-3
deploy/addons/auto-pause/hello_world.lua
deploy/addons/auto-pause/hello_world.lua
+0
-9
deploy/addons/auto-pause/notes.md
deploy/addons/auto-pause/notes.md
+0
-4
deploy/addons/auto-pause/unpause.lua
deploy/addons/auto-pause/unpause.lua
+58
-0
pkg/addons/config.go
pkg/addons/config.go
+6
-0
pkg/minikube/assets/addons.go
pkg/minikube/assets/addons.go
+28
-0
未找到文件。
deploy/addons/auto-pause/auto-pause.service
0 → 100644
浏览文件 @
8412efbc
Description
=
Auto Pause Service
[Service]
Type
=
simple
ExecStart
=
/usr/local/bin/auto-pause
Restart
=
always
[Install]
WantedBy
=
multi-user.target
\ No newline at end of file
deploy/addons/auto-pause/auto-pause.yaml
→
deploy/addons/auto-pause/auto-pause.yaml
.tmpl
浏览文件 @
8412efbc
...
...
@@ -24,15 +24,11 @@ spec:
type: File
- name: lua-script
hostPath:
path
:
/var/lib/minikube/hello_world.lua
type
:
File
-
name
:
mini-status
hostPath
:
path
:
/var/lib/minikube/pstatus.txt
path: /var/lib/minikube/unpause.lua
type: File
containers:
- name: auto-pause
image
:
"
haproxy"
image: "haproxy
:2.3.5
"
ports:
- name: https
containerPort: 6443
...
...
@@ -43,7 +39,5 @@ spec:
mountPath: /usr/local/etc/haproxy/haproxy.cfg
readOnly: true
- name: lua-script
mountPath
:
/etc/haproxy/hello_world.lua
-
name
:
mini-status
mountPath
:
/var/lib/minikube/pstatus.txt
mountPath: /etc/haproxy/unpause.lua
---
\ No newline at end of file
deploy/addons/auto-pause/haproxy.cfg
浏览文件 @
8412efbc
...
...
@@ -12,7 +12,7 @@ listen stats
# change haproxy.cfg file with the following
global
lua-load /etc/haproxy/
hello_world
.lua
lua-load /etc/haproxy/
unpause
.lua
############## Configure HAProxy Secure Frontend #############
frontend k8s-api-https-proxy
...
...
@@ -21,12 +21,15 @@ frontend k8s-api-https-proxy
tcp-request inspect-delay 5s
tcp-request content accept if { req.ssl_hello_type 1 }
default_backend k8s-api-https
############## Configure HAProxy SecureBackend #############
backend k8s-api-https
balance roundrobin
mode tcp
tcp-request content lua.foo_action
#tcp-request inspect-delay 10s
#tcp-request content lua.foo_action
tcp-request inspect-delay 10s
tcp-request content lua.unpause 192.168.49.2 8000
tcp-request content reject if { var(req.blocked) -m bool }
option tcplog
option tcp-check
default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100
...
...
deploy/addons/auto-pause/hello_world.lua
已删除
100644 → 0
浏览文件 @
5dfc3048
local
function
foo
(
txn
)
core
.
Info
(
"hello_world\n"
)
f
=
io.open
(
"/tmp/abc.txt"
,
"a"
)
f
:
write
(
"hello_world\n"
)
f
:
close
()
end
core
.
register_action
(
"foo_action"
,
{
'tcp-req'
},
foo
,
0
)
deploy/addons/auto-pause/notes.md
已删除
100644 → 0
浏览文件 @
5dfc3048
## Running in docker
```
docker run -p 38443:38443 -v $(pwd):/t -it --rm --name haproxy haproxy -f /t/haproxy.cfg
```
\ No newline at end of file
deploy/addons/auto-pause/unpause.lua
0 → 100644
浏览文件 @
8412efbc
local
function
unpause
(
txn
,
addr
,
port
)
core
.
Info
(
"hello_world\n"
)
if
not
addr
then
addr
=
'127.0.0.1'
end
if
not
port
then
port
=
5000
end
-- Set up a request to the service
local
hdrs
=
{
[
1
]
=
string.format
(
'host: %s:%s'
,
addr
,
port
),
[
2
]
=
'accept: */*'
,
[
3
]
=
'connection: close'
}
local
req
=
{
[
1
]
=
string.format
(
'GET /%s HTTP/1.1'
,
tostring
(
txn
.
f
:
src
())),
[
2
]
=
table.concat
(
hdrs
,
'
\r\n
'
),
[
3
]
=
'
\r\n
'
}
req
=
table.concat
(
req
,
'
\r\n
'
)
-- Use core.tcp to get an instance of the Socket class
local
socket
=
core
.
tcp
()
socket
:
settimeout
(
5
)
-- Connect to the service and send the request
if
socket
:
connect
(
addr
,
port
)
then
if
socket
:
send
(
req
)
then
-- Skip response headers
while
true
do
local
line
,
_
=
socket
:
receive
(
'*l'
)
if
not
line
then
break
end
if
line
==
''
then
break
end
end
-- Get response body, if any
local
content
=
socket
:
receive
(
'*a'
)
-- Check if this request should be allowed
if
content
and
content
==
'allow'
then
txn
:
set_var
(
'req.blocked'
,
false
)
return
end
else
core
.
Alert
(
'Could not connect to IP Checker server (send)'
)
end
socket
:
close
()
else
core
.
Alert
(
'Could not connect to IP Checker server (connect)'
)
end
-- The request should be blocked
txn
:
set_var
(
'req.blocked'
,
true
)
end
core
.
register_action
(
'unpause'
,
{
'tcp-req'
},
unpause
,
2
)
pkg/addons/config.go
浏览文件 @
8412efbc
...
...
@@ -42,6 +42,12 @@ var addonPodLabels = map[string]string{
// Addons is a list of all addons
var
Addons
=
[]
*
Addon
{
{
name
:
"auto-pause"
,
set
:
SetBool
,
callbacks
:
[]
setFn
{
enableOrDisableAddon
},
},
{
name
:
"dashboard"
,
set
:
SetBool
,
...
...
pkg/minikube/assets/addons.go
浏览文件 @
8412efbc
...
...
@@ -71,6 +71,34 @@ func (a *Addon) IsEnabled(cc *config.ClusterConfig) bool {
// Addons is the list of addons
// TODO: Make dynamically loadable: move this data to a .yaml file within each addon directory
var
Addons
=
map
[
string
]
*
Addon
{
"auto-pause"
:
NewAddon
([]
*
BinAsset
{
MustBinAsset
(
"deploy/addons/auto-pause/auto-pause.yaml.tmpl"
,
vmpath
.
GuestAddonsDir
,
"auto-pause.yaml"
,
"0640"
),
MustBinAsset
(
"deploy/addons/auto-pause/haproxy.cfg"
,
"/var/lib/minikube/"
,
"haproxy.cfg"
,
"0640"
),
MustBinAsset
(
"deploy/addons/auto-pause/unpause.lua"
,
"/var/lib/minikube/"
,
"unpause.lua"
,
"0640"
),
MustBinAsset
(
"deploy/addons/auto-pause/auto-pause.service"
,
"/etc/systemd/system/"
,
"auto-pause.service"
,
"0640"
),
//GuestPersistentDir
},
false
,
"auto-pause"
,
map
[
string
]
string
{
"haproxy"
:
"haproxy:2.3.5"
,
},
map
[
string
]
string
{
"haproxy"
:
"gcr.io"
,
}),
"dashboard"
:
NewAddon
([]
*
BinAsset
{
// We want to create the kubernetes-dashboard ns first so that every subsequent object can be created
MustBinAsset
(
"deploy/addons/dashboard/dashboard-ns.yaml"
,
vmpath
.
GuestAddonsDir
,
"dashboard-ns.yaml"
,
"0640"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录