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
f4a9b62d
Commit
f4a9b62d
authored
Feb 10, 2015
by
Jimmi Dyson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Configurable API prefix for kubectl proxy
parent
e27d534b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
kubectl.md
docs/kubectl.md
+1
-0
proxy.go
pkg/kubectl/cmd/proxy.go
+8
-1
proxy_server.go
pkg/kubectl/proxy_server.go
+2
-2
No files found.
docs/kubectl.md
View file @
f4a9b62d
...
...
@@ -49,6 +49,7 @@ Usage:
Available Flags:
--alsologtostderr=false: log to standard error as well as files
--api-prefix="/api/": Prefix to serve the proxied API under
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
...
...
pkg/kubectl/cmd/proxy.go
View file @
f4a9b62d
...
...
@@ -42,13 +42,20 @@ func (f *Factory) NewCmdProxy(out io.Writer) *cobra.Command {
if
!
strings
.
HasSuffix
(
staticPrefix
,
"/"
)
{
staticPrefix
+=
"/"
}
server
,
err
:=
kubectl
.
NewProxyServer
(
util
.
GetFlagString
(
cmd
,
"www"
),
staticPrefix
,
clientConfig
)
apiProxyPrefix
:=
util
.
GetFlagString
(
cmd
,
"api-prefix"
)
if
!
strings
.
HasSuffix
(
apiProxyPrefix
,
"/"
)
{
apiProxyPrefix
+=
"/"
}
server
,
err
:=
kubectl
.
NewProxyServer
(
util
.
GetFlagString
(
cmd
,
"www"
),
apiProxyPrefix
,
staticPrefix
,
clientConfig
)
checkErr
(
err
)
glog
.
Fatal
(
server
.
Serve
(
port
))
},
}
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
()
.
StringP
(
"api-prefix"
,
""
,
"/api/"
,
"Prefix to serve the proxied API under"
)
cmd
.
Flags
()
.
IntP
(
"port"
,
"p"
,
8001
,
"The port on which to run the proxy"
)
return
cmd
}
pkg/kubectl/proxy_server.go
View file @
f4a9b62d
...
...
@@ -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
,
staticPrefix
string
,
cfg
*
client
.
Config
)
(
*
ProxyServer
,
error
)
{
func
NewProxyServer
(
filebase
string
,
apiProxyPrefix
string
,
staticPrefix
string
,
cfg
*
client
.
Config
)
(
*
ProxyServer
,
error
)
{
prefix
:=
cfg
.
Prefix
if
prefix
==
""
{
prefix
=
"/api"
...
...
@@ -46,7 +46,7 @@ func NewProxyServer(filebase string, staticPrefix string, cfg *client.Config) (*
if
proxy
.
Transport
,
err
=
client
.
TransportFor
(
cfg
);
err
!=
nil
{
return
nil
,
err
}
http
.
Handle
(
"/api/"
,
http
.
StripPrefix
(
"/api/"
,
proxy
))
http
.
Handle
(
apiProxyPrefix
,
http
.
StripPrefix
(
apiProxyPrefix
,
proxy
))
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