@@ -18,32 +18,27 @@ limitations under the License.
18
18
package apply
19
19
20
20
import (
21
- "context"
22
21
"fmt"
23
22
"io"
24
23
25
24
"github.com/pkg/errors"
26
25
27
- apierrors "k8s.io/apimachinery/pkg/api/errors"
28
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
26
clientset "k8s.io/client-go/kubernetes"
30
- "k8s.io/klog/v2"
31
27
32
28
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
33
29
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
34
30
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
35
31
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
36
- kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
37
32
dnsaddon "k8s.io/kubernetes/cmd/kubeadm/app/phases/addons/dns"
38
33
proxyaddon "k8s.io/kubernetes/cmd/kubeadm/app/phases/addons/proxy"
39
34
"k8s.io/kubernetes/cmd/kubeadm/app/phases/upgrade"
40
35
)
41
36
42
- // NewAddonPhase returns the addon Cobra command
37
+ // NewAddonPhase returns a new addon phase.
43
38
func NewAddonPhase () workflow.Phase {
44
39
return workflow.Phase {
45
40
Name : "addon" ,
46
- Short : "Install required addons for passing conformance tests " ,
41
+ Short : "Install the default kubeadm addons " ,
47
42
Long : cmdutil .MacroCommandLongDescription ,
48
43
Phases : []workflow.Phase {
49
44
{
@@ -54,13 +49,13 @@ func NewAddonPhase() workflow.Phase {
54
49
},
55
50
{
56
51
Name : "coredns" ,
57
- Short : "Install the CoreDNS addon to a Kubernetes cluster " ,
52
+ Short : "Install the CoreDNS addon" ,
58
53
InheritFlags : getAddonPhaseFlags ("coredns" ),
59
54
Run : runCoreDNSAddon ,
60
55
},
61
56
{
62
57
Name : "kube-proxy" ,
63
- Short : "Install the kube-proxy addon to a Kubernetes cluster " ,
58
+ Short : "Install the kube-proxy addon" ,
64
59
InheritFlags : getAddonPhaseFlags ("kube-proxy" ),
65
60
Run : runKubeProxyAddon ,
66
61
},
@@ -74,10 +69,9 @@ func shouldUpgradeAddons(client clientset.Interface, cfg *kubeadmapi.InitConfigu
74
69
return false , errors .Wrapf (err , "failed to determine whether all the control plane instances have been upgraded" )
75
70
}
76
71
if len (unupgradedControlPlanes ) > 0 {
77
- fmt .Fprintf (out , "[upgrade/addons] skip upgrade addons because control plane instances %v have not been upgraded\n " , unupgradedControlPlanes )
72
+ fmt .Fprintf (out , "[upgrade/addons] Skipping upgrade of addons because control plane instances %v have not been upgraded\n " , unupgradedControlPlanes )
78
73
return false , nil
79
74
}
80
-
81
75
return true , nil
82
76
}
83
77
@@ -89,7 +83,7 @@ func getInitData(c workflow.RunData) (*kubeadmapi.InitConfiguration, clientset.I
89
83
return data .InitCfg (), data .Client (), data .PatchesDir (), data .OutputWriter (), data .DryRun (), nil
90
84
}
91
85
92
- // runCoreDNSAddon installs CoreDNS addon to a Kubernetes cluster
86
+ // runCoreDNSAddon installs the CoreDNS addon.
93
87
func runCoreDNSAddon (c workflow.RunData ) error {
94
88
cfg , client , patchesDir , out , dryRun , err := getInitData (c )
95
89
if err != nil {
@@ -104,25 +98,6 @@ func runCoreDNSAddon(c workflow.RunData) error {
104
98
return nil
105
99
}
106
100
107
- // If the coredns ConfigMap is missing, show a warning and assume that the
108
- // DNS addon was skipped during "kubeadm init", and that its redeployment on upgrade is not desired.
109
- //
110
- // TODO: remove this once "kubeadm upgrade apply" phases are supported:
111
- // https://github.com/kubernetes/kubeadm/issues/1318
112
- if _ , err := client .CoreV1 ().ConfigMaps (metav1 .NamespaceSystem ).Get (
113
- context .TODO (),
114
- kubeadmconstants .CoreDNSConfigMap ,
115
- metav1.GetOptions {},
116
- ); err != nil && apierrors .IsNotFound (err ) {
117
- klog .Warningf ("the ConfigMaps %q in the namespace %q were not found. " +
118
- "Assuming that a DNS server was not deployed for this cluster. " +
119
- "Note that once 'kubeadm upgrade apply' supports phases you " +
120
- "will have to skip the DNS upgrade manually" ,
121
- kubeadmconstants .CoreDNSConfigMap ,
122
- metav1 .NamespaceSystem )
123
- return nil
124
- }
125
-
126
101
// Upgrade CoreDNS
127
102
if err := dnsaddon .EnsureDNSAddon (& cfg .ClusterConfiguration , client , patchesDir , out , dryRun ); err != nil {
128
103
return err
@@ -131,7 +106,7 @@ func runCoreDNSAddon(c workflow.RunData) error {
131
106
return nil
132
107
}
133
108
134
- // runKubeProxyAddon installs KubeProxy addon to a Kubernetes cluster
109
+ // runKubeProxyAddon installs the KubeProxy addon.
135
110
func runKubeProxyAddon (c workflow.RunData ) error {
136
111
cfg , client , _ , out , dryRun , err := getInitData (c )
137
112
if err != nil {
@@ -146,25 +121,6 @@ func runKubeProxyAddon(c workflow.RunData) error {
146
121
return nil
147
122
}
148
123
149
- // If the kube-proxy ConfigMap is missing, show a warning and assume that kube-proxy
150
- // was skipped during "kubeadm init", and that its redeployment on upgrade is not desired.
151
- //
152
- // TODO: remove this once "kubeadm upgrade apply" phases are supported:
153
- // https://github.com/kubernetes/kubeadm/issues/1318
154
- if _ , err := client .CoreV1 ().ConfigMaps (metav1 .NamespaceSystem ).Get (
155
- context .TODO (),
156
- kubeadmconstants .KubeProxyConfigMap ,
157
- metav1.GetOptions {},
158
- ); err != nil && apierrors .IsNotFound (err ) {
159
- klog .Warningf ("the ConfigMap %q in the namespace %q was not found. " +
160
- "Assuming that kube-proxy was not deployed for this cluster. " +
161
- "Note that once 'kubeadm upgrade apply' supports phases you " +
162
- "will have to skip the kube-proxy upgrade manually" ,
163
- kubeadmconstants .KubeProxyConfigMap ,
164
- metav1 .NamespaceSystem )
165
- return nil
166
- }
167
-
168
124
// Upgrade kube-proxy
169
125
if err := proxyaddon .EnsureProxyAddon (& cfg .ClusterConfiguration , & cfg .LocalAPIEndpoint , client , out , dryRun ); err != nil {
170
126
return err
0 commit comments