mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Check kubeClient nil in Kubelet and bugfix
This commit is contained in:
parent
622c2bbd5e
commit
423a51b632
@ -1533,10 +1533,14 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
|
|||||||
key := envVar.ValueFrom.ConfigMapKeyRef.Key
|
key := envVar.ValueFrom.ConfigMapKeyRef.Key
|
||||||
configMap, ok := configMaps[name]
|
configMap, ok := configMaps[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if kl.kubeClient == nil {
|
||||||
|
return result, fmt.Errorf("Couldn't get configMap %v/%v, no kubeClient defined", pod.Namespace, name)
|
||||||
|
}
|
||||||
configMap, err = kl.kubeClient.Core().ConfigMaps(pod.Namespace).Get(name)
|
configMap, err = kl.kubeClient.Core().ConfigMaps(pod.Namespace).Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
configMaps[name] = configMap
|
||||||
}
|
}
|
||||||
runtimeVal, ok = configMap.Data[key]
|
runtimeVal, ok = configMap.Data[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -1547,10 +1551,14 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
|
|||||||
key := envVar.ValueFrom.SecretKeyRef.Key
|
key := envVar.ValueFrom.SecretKeyRef.Key
|
||||||
secret, ok := secrets[name]
|
secret, ok := secrets[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if kl.kubeClient == nil {
|
||||||
|
return result, fmt.Errorf("Couldn't get secret %v/%v, no kubeClient defined", pod.Namespace, name)
|
||||||
|
}
|
||||||
secret, err = kl.kubeClient.Core().Secrets(pod.Namespace).Get(name)
|
secret, err = kl.kubeClient.Core().Secrets(pod.Namespace).Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
secrets[name] = secret
|
||||||
}
|
}
|
||||||
runtimeValBytes, ok := secret.Data[key]
|
runtimeValBytes, ok := secret.Data[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user