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
c7628fae
Commit
c7628fae
authored
Aug 27, 2015
by
Ananya Kumar
Committed by
Mike Danese
Sep 11, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add daemon manager
parent
d59f7429
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
1 deletion
+68
-1
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+6
-0
controller_utils.go
pkg/controller/controller_utils.go
+38
-1
doc.go
pkg/controller/daemon/doc.go
+19
-0
manager.go
pkg/controller/daemon/manager.go
+0
-0
manager_test.go
pkg/controller/daemon/manager_test.go
+0
-0
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+5
-0
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
c7628fae
...
...
@@ -35,6 +35,7 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/controller/daemon"
"k8s.io/kubernetes/pkg/controller/endpoint"
"k8s.io/kubernetes/pkg/controller/namespace"
"k8s.io/kubernetes/pkg/controller/node"
...
...
@@ -63,6 +64,7 @@ type CMServer struct {
CloudConfigFile
string
ConcurrentEndpointSyncs
int
ConcurrentRCSyncs
int
ConcurrentDCSyncs
int
ServiceSyncPeriod
time
.
Duration
NodeSyncPeriod
time
.
Duration
ResourceQuotaSyncPeriod
time
.
Duration
...
...
@@ -98,6 +100,7 @@ func NewCMServer() *CMServer {
Address
:
net
.
ParseIP
(
"127.0.0.1"
),
ConcurrentEndpointSyncs
:
5
,
ConcurrentRCSyncs
:
5
,
ConcurrentDCSyncs
:
2
,
ServiceSyncPeriod
:
5
*
time
.
Minute
,
NodeSyncPeriod
:
10
*
time
.
Second
,
ResourceQuotaSyncPeriod
:
10
*
time
.
Second
,
...
...
@@ -213,6 +216,9 @@ func (s *CMServer) Run(_ []string) error {
controllerManager
:=
replicationControllerPkg
.
NewReplicationManager
(
kubeClient
,
replicationControllerPkg
.
BurstReplicas
)
go
controllerManager
.
Run
(
s
.
ConcurrentRCSyncs
,
util
.
NeverStop
)
daemonManager
:=
daemon
.
NewDaemonManager
(
kubeClient
)
go
daemonManager
.
Run
(
s
.
ConcurrentDCSyncs
,
util
.
NeverStop
)
cloud
,
err
:=
cloudprovider
.
InitCloudProvider
(
s
.
CloudProvider
,
s
.
CloudConfigFile
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Cloud provider could not be initialized: %v"
,
err
)
...
...
pkg/controller/controller_utils.go
View file @
c7628fae
...
...
@@ -20,6 +20,8 @@ import (
"fmt"
"time"
"sync/atomic"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/latest"
...
...
@@ -28,9 +30,9 @@ import (
"k8s.io/kubernetes/pkg/client/record"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"sync/atomic"
)
const
(
...
...
@@ -213,6 +215,8 @@ func NewControllerExpectations() *ControllerExpectations {
type
PodControlInterface
interface
{
// CreateReplica creates new replicated pods according to the spec.
CreateReplica
(
namespace
string
,
controller
*
api
.
ReplicationController
)
error
// CreateReplicaOnNodes creates a new pod according to the spec, on a specified list of nodes.
CreateReplicaOnNode
(
namespace
string
,
controller
*
expapi
.
DaemonSet
,
nodeNames
string
)
error
// DeletePod deletes the pod identified by podID.
DeletePod
(
namespace
string
,
podID
string
)
error
}
...
...
@@ -290,6 +294,39 @@ func (r RealPodControl) CreateReplica(namespace string, controller *api.Replicat
return
nil
}
func
(
r
RealPodControl
)
CreateReplicaOnNode
(
namespace
string
,
controller
*
expapi
.
DaemonSet
,
nodeName
string
)
error
{
desiredLabels
:=
getReplicaLabelSet
(
controller
.
Spec
.
Template
)
desiredAnnotations
,
err
:=
getReplicaAnnotationSet
(
controller
.
Spec
.
Template
,
controller
)
if
err
!=
nil
{
return
err
}
prefix
:=
getReplicaPrefix
(
controller
.
Name
)
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
desiredLabels
,
Annotations
:
desiredAnnotations
,
GenerateName
:
prefix
,
},
}
if
err
:=
api
.
Scheme
.
Convert
(
&
controller
.
Spec
.
Template
.
Spec
,
&
pod
.
Spec
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to convert pod template: %v"
,
err
)
}
if
labels
.
Set
(
pod
.
Labels
)
.
AsSelector
()
.
Empty
()
{
return
fmt
.
Errorf
(
"unable to create pod replica, no labels"
)
}
pod
.
Spec
.
NodeName
=
nodeName
if
newPod
,
err
:=
r
.
KubeClient
.
Pods
(
namespace
)
.
Create
(
pod
);
err
!=
nil
{
r
.
Recorder
.
Eventf
(
controller
,
"failedCreate"
,
"Error creating: %v"
,
err
)
return
fmt
.
Errorf
(
"unable to create pod replica: %v"
,
err
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Controller %v created pod %v"
,
controller
.
Name
,
newPod
.
Name
)
r
.
Recorder
.
Eventf
(
controller
,
"successfulCreate"
,
"Created pod: %v"
,
newPod
.
Name
)
}
return
nil
}
func
(
r
RealPodControl
)
DeletePod
(
namespace
,
podID
string
)
error
{
return
r
.
KubeClient
.
Pods
(
namespace
)
.
Delete
(
podID
,
nil
)
}
...
...
pkg/controller/daemon/doc.go
0 → 100644
View file @
c7628fae
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package daemon contains logic for watching and synchronizing
// daemons.
package
daemon
pkg/controller/daemon/manager.go
0 → 100644
View file @
c7628fae
This diff is collapsed.
Click to expand it.
pkg/controller/daemon/manager_test.go
0 → 100644
View file @
c7628fae
This diff is collapsed.
Click to expand it.
pkg/controller/replication/replication_controller_test.go
View file @
c7628fae
...
...
@@ -31,6 +31,7 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/securitycontext"
...
...
@@ -69,6 +70,10 @@ func (f *FakePodControl) CreateReplica(namespace string, spec *api.ReplicationCo
return
nil
}
func
(
f
*
FakePodControl
)
CreateReplicaOnNode
(
namespace
string
,
daemon
*
expapi
.
DaemonSet
,
nodeName
string
)
error
{
return
nil
}
func
(
f
*
FakePodControl
)
DeletePod
(
namespace
string
,
podName
string
)
error
{
f
.
lock
.
Lock
()
defer
f
.
lock
.
Unlock
()
...
...
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