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
5760fe19
Commit
5760fe19
authored
Jun 23, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use ca.crt as client certificate authority for inClusterConfig
parent
56bde334
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
helper.go
pkg/client/helper.go
+11
-3
No files found.
pkg/client/helper.go
View file @
5760fe19
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
"strings"
"strings"
"time"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
...
@@ -236,17 +237,24 @@ func NewOrDie(c *Config) *Client {
...
@@ -236,17 +237,24 @@ func NewOrDie(c *Config) *Client {
// running inside a pod running on kuberenetes. It will return an error if
// running inside a pod running on kuberenetes. It will return an error if
// called from a process not running in a kubernetes environment.
// called from a process not running in a kubernetes environment.
func
InClusterConfig
()
(
*
Config
,
error
)
{
func
InClusterConfig
()
(
*
Config
,
error
)
{
token
,
err
:=
ioutil
.
ReadFile
(
"/var/run/secrets/kubernetes.io/serviceaccount/
token"
)
token
,
err
:=
ioutil
.
ReadFile
(
"/var/run/secrets/kubernetes.io/serviceaccount/
"
+
api
.
ServiceAccountTokenKey
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
tlsClientConfig
:=
TLSClientConfig
{}
rootCAFile
:=
"/var/run/secrets/kubernetes.io/serviceaccount/"
+
api
.
ServiceAccountRootCAKey
if
_
,
err
:=
util
.
CertPoolFromFile
(
rootCAFile
);
err
!=
nil
{
glog
.
Errorf
(
"expected to load root ca config from %s, but got err: %v"
,
rootCAFile
,
err
)
}
else
{
tlsClientConfig
.
CAFile
=
rootCAFile
}
return
&
Config
{
return
&
Config
{
// TODO: switch to using cluster DNS.
// TODO: switch to using cluster DNS.
Host
:
"https://"
+
net
.
JoinHostPort
(
os
.
Getenv
(
"KUBERNETES_SERVICE_HOST"
),
os
.
Getenv
(
"KUBERNETES_SERVICE_PORT"
)),
Host
:
"https://"
+
net
.
JoinHostPort
(
os
.
Getenv
(
"KUBERNETES_SERVICE_HOST"
),
os
.
Getenv
(
"KUBERNETES_SERVICE_PORT"
)),
Version
:
"v1beta3"
,
Version
:
"v1beta3"
,
BearerToken
:
string
(
token
),
BearerToken
:
string
(
token
),
// TODO: package certs along with the token
TLSClientConfig
:
tlsClientConfig
,
Insecure
:
true
,
},
nil
},
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