Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
42fec8ec
Commit
42fec8ec
authored
Feb 05, 2015
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4110 from jimmidyson/proxy-tweaks
kubectl proxy: make static prefix configurable
parents
25134812
e2baf049
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
5 deletions
+12
-5
kubectl.md
docs/kubectl.md
+2
-1
proxy.go
pkg/kubectl/cmd/proxy.go
+8
-2
proxy_server.go
pkg/kubectl/proxy_server.go
+2
-2
No files found.
docs/kubectl.md
View file @
42fec8ec
...
...
@@ -73,7 +73,8 @@ Usage:
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
-w, --www="": Also serve static files from the given directory under the prefix /static
-w, --www="": Also serve static files from the given directory under the specified prefix
-P, --www-prefix="/static/": Prefix to serve static files under, if static file dir is specified
```
...
...
pkg/kubectl/cmd/proxy.go
View file @
42fec8ec
...
...
@@ -18,6 +18,7 @@ package cmd
import
(
"io"
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/golang/glog"
...
...
@@ -36,12 +37,17 @@ func (f *Factory) NewCmdProxy(out io.Writer) *cobra.Command {
clientConfig
,
err
:=
f
.
ClientConfig
(
cmd
)
checkErr
(
err
)
server
,
err
:=
kubectl
.
NewProxyServer
(
GetFlagString
(
cmd
,
"www"
),
clientConfig
)
staticPrefix
:=
GetFlagString
(
cmd
,
"www-prefix"
)
if
!
strings
.
HasSuffix
(
staticPrefix
,
"/"
)
{
staticPrefix
+=
"/"
}
server
,
err
:=
kubectl
.
NewProxyServer
(
GetFlagString
(
cmd
,
"www"
),
staticPrefix
,
clientConfig
)
checkErr
(
err
)
glog
.
Fatal
(
server
.
Serve
(
port
))
},
}
cmd
.
Flags
()
.
StringP
(
"www"
,
"w"
,
""
,
"Also serve static files from the given directory under the prefix /static"
)
cmd
.
Flags
()
.
StringP
(
"www"
,
"w"
,
""
,
"Also serve static files from the given directory under the specified prefix"
)
cmd
.
Flags
()
.
StringP
(
"www-prefix"
,
"P"
,
"/static/"
,
"Prefix to serve static files under, if static file dir is specified"
)
cmd
.
Flags
()
.
IntP
(
"port"
,
"p"
,
8001
,
"The port on which to run the proxy"
)
return
cmd
}
pkg/kubectl/proxy_server.go
View file @
42fec8ec
...
...
@@ -33,7 +33,7 @@ type ProxyServer struct {
// NewProxyServer creates and installs a new ProxyServer.
// It automatically registers the created ProxyServer to http.DefaultServeMux.
func
NewProxyServer
(
filebase
string
,
cfg
*
client
.
Config
)
(
*
ProxyServer
,
error
)
{
func
NewProxyServer
(
filebase
string
,
staticPrefix
string
,
cfg
*
client
.
Config
)
(
*
ProxyServer
,
error
)
{
prefix
:=
cfg
.
Prefix
if
prefix
==
""
{
prefix
=
"/api"
...
...
@@ -47,7 +47,7 @@ func NewProxyServer(filebase string, cfg *client.Config) (*ProxyServer, error) {
return
nil
,
err
}
http
.
Handle
(
"/api/"
,
http
.
StripPrefix
(
"/api/"
,
proxy
))
http
.
Handle
(
"/static/"
,
newFileHandler
(
"/static/"
,
filebase
))
http
.
Handle
(
staticPrefix
,
newFileHandler
(
staticPrefix
,
filebase
))
return
proxy
,
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment