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
b9542ef0
Unverified
Commit
b9542ef0
authored
Aug 20, 2020
by
Brad Davidson
Committed by
GitHub
Aug 20, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2144 from brandond/2140_backport
Update helm-controller to v0.6.5 to add helm job toleration
parents
6b595318
defc0da0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
172 additions
and
69 deletions
+172
-69
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-2
image-list.txt
scripts/airgap/image-list.txt
+1
-1
types.go
...ncher/helm-controller/pkg/apis/helm.cattle.io/v1/types.go
+2
-0
factory.go
...oller/pkg/generated/controllers/helm.cattle.io/factory.go
+25
-10
helmchart.go
.../pkg/generated/controllers/helm.cattle.io/v1/helmchart.go
+23
-22
controller.go
...github.com/rancher/helm-controller/pkg/helm/controller.go
+117
-32
modules.txt
vendor/modules.txt
+1
-1
No files found.
go.mod
View file @
b9542ef0
...
...
@@ -99,7 +99,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8 // indirect
github.com/rancher/dynamiclistener v0.2.0
github.com/rancher/helm-controller v0.6.
0
github.com/rancher/helm-controller v0.6.
5
github.com/rancher/kine v0.4.0
github.com/rancher/remotedialer v0.2.0
github.com/rancher/wrangler v0.6.1
...
...
go.sum
View file @
b9542ef0
...
...
@@ -631,8 +631,8 @@ github.com/rancher/dynamiclistener v0.2.0 h1:KucYwJXVVGhZ/NndfMCeQoCafT/VN7kvqSG
github.com/rancher/dynamiclistener v0.2.0/go.mod h1:fs/dxyNcB3YT6W9fVz4bDGfhmSQS17QQup6BIcGF++s=
github.com/rancher/flannel v0.11.0-k3s.2 h1:0GVr5ORAIvcri1LYTE8eMQ+NrRbuPeIniPaW51IzLco=
github.com/rancher/flannel v0.11.0-k3s.2/go.mod h1:Hn4ZV+eq0LhLZP63xZnxdGwXEoRSxs5sxELxu27M3UA=
github.com/rancher/helm-controller v0.6.
0 h1:nFptBZFWpHga65M6bP04BZGLlzeMgezAXdsOwaB8t+4
=
github.com/rancher/helm-controller v0.6.
0
/go.mod h1:ZylsxIMGNADRPRNW+NiBWhrwwks9vnKLQiCHYWb6Bi0=
github.com/rancher/helm-controller v0.6.
5 h1:gL6R3fbsBFBnrp2Wc36zn0zLQ8q2ckbLpfaN2XkrLVE
=
github.com/rancher/helm-controller v0.6.
5
/go.mod h1:ZylsxIMGNADRPRNW+NiBWhrwwks9vnKLQiCHYWb6Bi0=
github.com/rancher/juju-to-pkg-errors v0.0.0-20200701001603-16f3c28b59bd h1:KPnQuOFWU6Jm7dTadhZ9TCVf6Y5NxoSyUjwkbD7En5Q=
github.com/rancher/juju-to-pkg-errors v0.0.0-20200701001603-16f3c28b59bd/go.mod h1:QYmg8cqWPPfIbpEuhtJbEdWwA6PEKSY016Z6EdfL9+8=
github.com/rancher/kine v0.4.0 h1:1IhWy3TzjExG8xnj46eyUEWdzqNAD1WrgL4eEBKm6Uc=
...
...
scripts/airgap/image-list.txt
View file @
b9542ef0
docker.io/rancher/coredns-coredns:1.6.9
docker.io/rancher/klipper-helm:v0.2.
5
docker.io/rancher/klipper-helm:v0.2.
7
docker.io/rancher/klipper-lb:v0.1.2
docker.io/rancher/library-traefik:1.7.19
docker.io/rancher/local-path-provisioner:v0.0.11
...
...
vendor/github.com/rancher/helm-controller/pkg/apis/helm.cattle.io/v1/types.go
View file @
b9542ef0
...
...
@@ -24,6 +24,8 @@ type HelmChartSpec struct {
Set
map
[
string
]
intstr
.
IntOrString
`json:"set,omitempty"`
ValuesContent
string
`json:"valuesContent,omitempty"`
HelmVersion
string
`json:"helmVersion,omitempty"`
Bootstrap
bool
`json:"bootstrap,omitempty"`
ChartContent
string
`json:"chartContent,omitempty"`
}
type
HelmChartStatus
struct
{
...
...
vendor/github.com/rancher/helm-controller/pkg/generated/controllers/helm.cattle.io/factory.go
View file @
b9542ef0
...
...
@@ -52,18 +52,23 @@ func NewFactoryFromConfigOrDie(config *rest.Config) *Factory {
}
func
NewFactoryFromConfig
(
config
*
rest
.
Config
)
(
*
Factory
,
error
)
{
cs
,
err
:=
clientset
.
NewForConfig
(
config
)
if
err
!=
nil
{
return
nil
,
err
}
informerFactory
:=
informers
.
NewSharedInformerFactory
(
cs
,
2
*
time
.
Hour
)
return
NewFactory
(
cs
,
informerFactory
),
nil
return
NewFactoryFromConfigWithOptions
(
config
,
nil
)
}
func
NewFactoryFromConfigWithNamespace
(
config
*
rest
.
Config
,
namespace
string
)
(
*
Factory
,
error
)
{
if
namespace
==
""
{
return
NewFactoryFromConfig
(
config
)
return
NewFactoryFromConfigWithOptions
(
config
,
&
FactoryOptions
{
Namespace
:
namespace
,
})
}
type
FactoryOptions
struct
{
Namespace
string
Resync
time
.
Duration
}
func
NewFactoryFromConfigWithOptions
(
config
*
rest
.
Config
,
opts
*
FactoryOptions
)
(
*
Factory
,
error
)
{
if
opts
==
nil
{
opts
=
&
FactoryOptions
{}
}
cs
,
err
:=
clientset
.
NewForConfig
(
config
)
...
...
@@ -71,7 +76,17 @@ func NewFactoryFromConfigWithNamespace(config *rest.Config, namespace string) (*
return
nil
,
err
}
informerFactory
:=
informers
.
NewSharedInformerFactoryWithOptions
(
cs
,
2
*
time
.
Hour
,
informers
.
WithNamespace
(
namespace
))
resync
:=
opts
.
Resync
if
resync
==
0
{
resync
=
2
*
time
.
Hour
}
if
opts
.
Namespace
==
""
{
informerFactory
:=
informers
.
NewSharedInformerFactory
(
cs
,
resync
)
return
NewFactory
(
cs
,
informerFactory
),
nil
}
informerFactory
:=
informers
.
NewSharedInformerFactoryWithOptions
(
cs
,
resync
,
informers
.
WithNamespace
(
opts
.
Namespace
))
return
NewFactory
(
cs
,
informerFactory
),
nil
}
...
...
vendor/github.com/rancher/helm-controller/pkg/generated/controllers/helm.cattle.io/v1/helmchart.go
View file @
b9542ef0
...
...
@@ -29,6 +29,7 @@ import (
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/condition"
"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/kv"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -267,6 +268,7 @@ func RegisterHelmChartGeneratingHandler(ctx context.Context, controller HelmChar
if
opts
!=
nil
{
statusHandler
.
opts
=
*
opts
}
controller
.
OnChange
(
ctx
,
name
,
statusHandler
.
Remove
)
RegisterHelmChartStatusHandler
(
ctx
,
controller
,
condition
,
name
,
statusHandler
.
Handle
)
}
...
...
@@ -281,7 +283,7 @@ func (a *helmChartStatusHandler) sync(key string, obj *v1.HelmChart) (*v1.HelmCh
return
obj
,
nil
}
origStatus
:=
obj
.
Status
origStatus
:=
obj
.
Status
.
DeepCopy
()
obj
=
obj
.
DeepCopy
()
newStatus
,
err
:=
a
.
handler
(
obj
,
obj
.
Status
)
if
err
!=
nil
{
...
...
@@ -289,16 +291,16 @@ func (a *helmChartStatusHandler) sync(key string, obj *v1.HelmChart) (*v1.HelmCh
newStatus
=
*
origStatus
.
DeepCopy
()
}
obj
.
Status
=
newStatus
if
a
.
condition
!=
""
{
if
errors
.
IsConflict
(
err
)
{
a
.
condition
.
SetError
(
obj
,
""
,
nil
)
a
.
condition
.
SetError
(
&
newStatus
,
""
,
nil
)
}
else
{
a
.
condition
.
SetError
(
obj
,
""
,
err
)
a
.
condition
.
SetError
(
&
newStatus
,
""
,
err
)
}
}
if
!
equality
.
Semantic
.
DeepEqual
(
origStatus
,
obj
.
Status
)
{
if
!
equality
.
Semantic
.
DeepEqual
(
origStatus
,
&
new
Status
)
{
var
newErr
error
obj
.
Status
=
newStatus
obj
,
newErr
=
a
.
client
.
UpdateStatus
(
obj
)
if
err
==
nil
{
err
=
newErr
...
...
@@ -315,29 +317,28 @@ type helmChartGeneratingHandler struct {
name
string
}
func
(
a
*
helmChartGeneratingHandler
)
Handle
(
obj
*
v1
.
HelmChart
,
status
v1
.
HelmChartStatus
)
(
v1
.
HelmChartStatus
,
error
)
{
objs
,
newStatus
,
err
:=
a
.
HelmChartGeneratingHandler
(
obj
,
status
)
if
err
!=
nil
{
return
newStatus
,
err
func
(
a
*
helmChartGeneratingHandler
)
Remove
(
key
string
,
obj
*
v1
.
HelmChart
)
(
*
v1
.
HelmChart
,
error
)
{
if
obj
!=
nil
{
return
obj
,
nil
}
apply
:=
a
.
apply
if
!
a
.
opts
.
DynamicLookup
{
apply
=
apply
.
WithStrictCaching
()
}
obj
=
&
v1
.
HelmChart
{}
obj
.
Namespace
,
obj
.
Name
=
kv
.
RSplit
(
key
,
"/"
)
obj
.
SetGroupVersionKind
(
a
.
gvk
)
if
!
a
.
opts
.
AllowCrossNamespace
&&
!
a
.
opts
.
AllowClusterScoped
{
apply
=
apply
.
WithSetOwnerReference
(
true
,
false
)
.
WithDefaultNamespace
(
obj
.
GetNamespace
()
)
.
WithListerNamespace
(
obj
.
GetNamespace
()
)
}
return
nil
,
generic
.
ConfigureApplyForObject
(
a
.
apply
,
obj
,
&
a
.
opts
)
.
WithOwner
(
obj
)
.
WithSetID
(
a
.
name
)
.
ApplyObjects
(
)
}
if
!
a
.
opts
.
AllowClusterScoped
{
apply
=
apply
.
WithRestrictClusterScoped
()
func
(
a
*
helmChartGeneratingHandler
)
Handle
(
obj
*
v1
.
HelmChart
,
status
v1
.
HelmChartStatus
)
(
v1
.
HelmChartStatus
,
error
)
{
objs
,
newStatus
,
err
:=
a
.
HelmChartGeneratingHandler
(
obj
,
status
)
if
err
!=
nil
{
return
newStatus
,
err
}
return
newStatus
,
apply
.
return
newStatus
,
generic
.
ConfigureApplyForObject
(
a
.
apply
,
obj
,
&
a
.
opts
)
.
WithOwner
(
obj
)
.
WithSetID
(
a
.
name
)
.
ApplyObjects
(
objs
...
)
...
...
vendor/github.com/rancher/helm-controller/pkg/helm/controller.go
View file @
b9542ef0
...
...
@@ -21,7 +21,6 @@ import (
rbac
"k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/errors"
meta
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
...
...
@@ -39,7 +38,7 @@ type Controller struct {
}
const
(
image
=
"rancher/klipper-helm:v0.2.
5
"
image
=
"rancher/klipper-helm:v0.2.
7
"
Label
=
"helmcharts.helm.cattle.io/chart"
CRDName
=
"helmcharts.helm.cattle.io"
Name
=
"helm-controller"
...
...
@@ -54,7 +53,7 @@ func Register(ctx context.Context, apply apply.Apply,
apply
=
apply
.
WithSetID
(
Name
)
.
WithCacheTypes
(
helms
,
jobs
,
crbs
,
sas
,
cm
)
.
WithStrictCaching
()
.
WithPatcher
(
batch
.
SchemeGroupVersion
.
WithKind
(
"Job"
),
func
(
namespace
,
name
string
,
pt
types
.
PatchType
,
data
[]
byte
)
(
runtime
.
Object
,
error
)
{
err
:=
jobs
.
Delete
(
namespace
,
name
,
&
meta
v1
.
DeleteOptions
{})
err
:=
jobs
.
Delete
(
namespace
,
name
,
&
meta
.
DeleteOptions
{})
if
err
==
nil
{
return
nil
,
fmt
.
Errorf
(
"replace job"
)
}
...
...
@@ -94,17 +93,20 @@ func (c *Controller) OnHelmChanged(key string, chart *helmv1.HelmChart) (*helmv1
return
nil
,
nil
}
if
chart
.
Spec
.
Chart
==
""
{
if
chart
.
Spec
.
Chart
==
""
&&
chart
.
Spec
.
ChartContent
==
""
{
return
chart
,
nil
}
objs
:=
objectset
.
NewObjectSet
()
job
,
c
onfigMap
:=
job
(
chart
)
job
,
valuesConfigMap
,
contentC
onfigMap
:=
job
(
chart
)
objs
.
Add
(
serviceAccount
(
chart
))
objs
.
Add
(
roleBinding
(
chart
))
objs
.
Add
(
job
)
if
configMap
!=
nil
{
objs
.
Add
(
configMap
)
if
valuesConfigMap
!=
nil
{
objs
.
Add
(
valuesConfigMap
)
}
if
contentConfigMap
!=
nil
{
objs
.
Add
(
contentConfigMap
)
}
if
err
:=
c
.
apply
.
WithOwner
(
chart
)
.
Apply
(
objs
);
err
!=
nil
{
...
...
@@ -120,7 +122,7 @@ func (c *Controller) OnHelmRemove(key string, chart *helmv1.HelmChart) (*helmv1.
if
chart
.
Spec
.
Chart
==
""
{
return
chart
,
nil
}
job
,
_
:=
job
(
chart
)
job
,
_
,
_
:=
job
(
chart
)
job
,
err
:=
c
.
jobsCache
.
Get
(
chart
.
Namespace
,
job
.
Name
)
if
errors
.
IsNotFound
(
err
)
{
...
...
@@ -147,7 +149,7 @@ func (c *Controller) OnHelmRemove(key string, chart *helmv1.HelmChart) (*helmv1.
return
newChart
,
c
.
apply
.
WithOwner
(
newChart
)
.
Apply
(
objectset
.
NewObjectSet
())
}
func
job
(
chart
*
helmv1
.
HelmChart
)
(
*
batch
.
Job
,
*
core
.
ConfigMap
)
{
func
job
(
chart
*
helmv1
.
HelmChart
)
(
*
batch
.
Job
,
*
core
.
ConfigMap
,
*
core
.
ConfigMap
)
{
oneThousand
:=
int32
(
1000
)
valuesHash
:=
sha256
.
Sum256
([]
byte
(
chart
.
Spec
.
ValuesContent
))
...
...
@@ -155,6 +157,7 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap) {
if
chart
.
DeletionTimestamp
!=
nil
{
action
=
"delete"
}
job
:=
&
batch
.
Job
{
TypeMeta
:
meta
.
TypeMeta
{
APIVersion
:
"batch/v1"
,
...
...
@@ -224,36 +227,41 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap) {
},
},
}
setProxyEnv
(
job
)
configMap
:=
configMap
(
chart
)
if
configMap
==
nil
{
return
job
,
nil
}
job
.
Spec
.
Template
.
Spec
.
Volumes
=
[]
core
.
Volume
{
{
Name
:
"values"
,
VolumeSource
:
core
.
VolumeSource
{
ConfigMap
:
&
core
.
ConfigMapVolumeSource
{
LocalObjectReference
:
core
.
LocalObjectReference
{
Name
:
configMap
.
Name
,
},
},
if
chart
.
Spec
.
Bootstrap
{
job
.
Spec
.
Template
.
Spec
.
HostNetwork
=
true
job
.
Spec
.
Template
.
Spec
.
Tolerations
=
[]
core
.
Toleration
{
{
Key
:
"node.kubernetes.io/not-ready"
,
Effect
:
"NoSchedule"
,
},
},
{
Key
:
"node.cloudprovider.kubernetes.io/uninitialized"
,
Operator
:
core
.
TolerationOpEqual
,
Value
:
"true"
,
Effect
:
"NoSchedule"
,
},
}
job
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Env
=
append
(
job
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Env
,
[]
core
.
EnvVar
{
{
Name
:
"KUBERNETES_SERVICE_HOST"
,
Value
:
"127.0.0.1"
},
{
Name
:
"KUBERNETES_SERVICE_PORT"
,
Value
:
"6443"
},
}
...
)
job
.
Spec
.
Template
.
Spec
.
NodeSelector
=
make
(
map
[
string
]
string
)
job
.
Spec
.
Template
.
Spec
.
NodeSelector
[
"node-role.kubernetes.io/master"
]
=
"true"
}
job
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
VolumeMounts
=
[]
core
.
VolumeMount
{
{
MountPath
:
"/config"
,
Name
:
"values"
,
},
}
setProxyEnv
(
job
)
valueConfigMap
:=
setValuesConfigMap
(
job
,
chart
)
contentConfigMap
:=
setContentConfigMap
(
job
,
chart
)
return
job
,
c
onfigMap
return
job
,
valueConfigMap
,
contentC
onfigMap
}
func
c
onfigMap
(
chart
*
helmv1
.
HelmChart
)
*
core
.
ConfigMap
{
func
valuesC
onfigMap
(
chart
*
helmv1
.
HelmChart
)
*
core
.
ConfigMap
{
if
chart
.
Spec
.
ValuesContent
==
""
{
return
nil
}
...
...
@@ -380,3 +388,80 @@ func setProxyEnv(job *batch.Job) {
envar
)
}
}
func
contentConfigMap
(
chart
*
helmv1
.
HelmChart
)
*
core
.
ConfigMap
{
if
chart
.
Spec
.
ChartContent
==
""
{
return
nil
}
return
&
core
.
ConfigMap
{
TypeMeta
:
meta
.
TypeMeta
{
APIVersion
:
"v1"
,
Kind
:
"ConfigMap"
,
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
fmt
.
Sprintf
(
"chart-content-%s"
,
chart
.
Name
),
Namespace
:
chart
.
Namespace
,
},
Data
:
map
[
string
]
string
{
fmt
.
Sprintf
(
"%s.tgz.base64"
,
chart
.
Name
)
:
chart
.
Spec
.
ChartContent
,
},
}
}
func
setValuesConfigMap
(
job
*
batch
.
Job
,
chart
*
helmv1
.
HelmChart
)
*
core
.
ConfigMap
{
configMap
:=
valuesConfigMap
(
chart
)
if
configMap
==
nil
{
return
nil
}
job
.
Spec
.
Template
.
Spec
.
Volumes
=
append
(
job
.
Spec
.
Template
.
Spec
.
Volumes
,
[]
core
.
Volume
{
{
Name
:
"values"
,
VolumeSource
:
core
.
VolumeSource
{
ConfigMap
:
&
core
.
ConfigMapVolumeSource
{
LocalObjectReference
:
core
.
LocalObjectReference
{
Name
:
configMap
.
Name
,
},
},
},
},
}
...
)
job
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
VolumeMounts
=
append
(
job
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
VolumeMounts
,
[]
core
.
VolumeMount
{
{
MountPath
:
"/config"
,
Name
:
"values"
,
},
}
...
)
return
configMap
}
func
setContentConfigMap
(
job
*
batch
.
Job
,
chart
*
helmv1
.
HelmChart
)
*
core
.
ConfigMap
{
configMap
:=
contentConfigMap
(
chart
)
if
configMap
==
nil
{
return
nil
}
job
.
Spec
.
Template
.
Spec
.
Volumes
=
append
(
job
.
Spec
.
Template
.
Spec
.
Volumes
,
[]
core
.
Volume
{
{
Name
:
"content"
,
VolumeSource
:
core
.
VolumeSource
{
ConfigMap
:
&
core
.
ConfigMapVolumeSource
{
LocalObjectReference
:
core
.
LocalObjectReference
{
Name
:
configMap
.
Name
,
},
},
},
},
}
...
)
job
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
VolumeMounts
=
append
(
job
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
VolumeMounts
,
[]
core
.
VolumeMount
{
{
MountPath
:
"/chart"
,
Name
:
"content"
,
},
}
...
)
return
configMap
}
vendor/modules.txt
View file @
b9542ef0
...
...
@@ -724,7 +724,7 @@ github.com/rancher/dynamiclistener/factory
github.com/rancher/dynamiclistener/storage/file
github.com/rancher/dynamiclistener/storage/kubernetes
github.com/rancher/dynamiclistener/storage/memory
# github.com/rancher/helm-controller v0.6.
0
# github.com/rancher/helm-controller v0.6.
5
github.com/rancher/helm-controller/pkg/apis/helm.cattle.io
github.com/rancher/helm-controller/pkg/apis/helm.cattle.io/v1
github.com/rancher/helm-controller/pkg/generated/clientset/versioned
...
...
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