-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathagent.go
More file actions
169 lines (152 loc) · 4.84 KB
/
Copy pathagent.go
File metadata and controls
169 lines (152 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package main
import (
"context"
"github.com/spf13/cobra"
"github.com/openshift/installer/cmd/openshift-install/agent"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent/agentconfig"
"github.com/openshift/installer/pkg/asset/agent/configimage"
"github.com/openshift/installer/pkg/asset/agent/image"
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/agent/mirror"
"github.com/openshift/installer/pkg/asset/kubeconfig"
"github.com/openshift/installer/pkg/asset/password"
"github.com/openshift/installer/pkg/asset/tls"
)
func newAgentCmd(ctx context.Context) *cobra.Command {
agentCmd := &cobra.Command{
Use: "agent",
Short: "Commands for supporting cluster installation using agent installer",
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}
agentCmd.AddCommand(newAgentCreateCmd(ctx))
agentCmd.AddCommand(agent.NewWaitForCmd())
agentCmd.AddCommand(newAgentGraphCmd())
agentCmd.AddCommand(agent.NewGatherCmd())
return agentCmd
}
var (
agentConfigTarget = target{
// TODO: remove template wording when interactive survey has been implemented
name: "Agent Config Template",
command: &cobra.Command{
Use: "agent-config-template",
Short: "Generates a template of the agent config manifest used by the agent installer",
Args: cobra.ExactArgs(0),
},
assets: []asset.WritableAsset{
&agentconfig.AgentConfig{},
},
}
agentManifestsTarget = target{
name: "Cluster Manifests",
command: &cobra.Command{
Use: "cluster-manifests",
Short: "Generates the cluster definition manifests used by the agent installer",
Args: cobra.ExactArgs(0),
},
assets: []asset.WritableAsset{
&manifests.AgentManifests{},
&mirror.RegistriesConf{},
&mirror.CaBundle{},
},
}
agentImageTarget = target{
name: "Agent ISO Image",
command: &cobra.Command{
Use: "image",
Short: "Generates a bootable image containing all the information needed to deploy a cluster",
Args: cobra.ExactArgs(0),
},
assets: []asset.WritableAsset{
&image.AgentImage{},
&kubeconfig.AgentAdminClient{},
&password.KubeadminPassword{},
},
}
agentConfigImageTarget = target{
name: "Agent Config Image",
command: &cobra.Command{
Use: "config-image",
Short: "Generates an ISO containing configuration files only",
Args: cobra.ExactArgs(0),
},
assets: []asset.WritableAsset{
&configimage.ConfigImage{},
&kubeconfig.AgentAdminClient{},
&password.KubeadminPassword{},
},
}
agentPXEFilesTarget = target{
name: "Agent PXE Files",
command: &cobra.Command{
Use: "pxe-files",
Short: "Generates PXE bootable image files containing all the information needed to deploy a cluster",
Args: cobra.ExactArgs(0),
},
assets: []asset.WritableAsset{
&image.AgentPXEFiles{},
&kubeconfig.AgentAdminClient{},
&password.KubeadminPassword{},
},
}
agentUnconfiguredIgnitionTarget = target{
name: "Agent unconfigured ignition",
command: &cobra.Command{
Use: "unconfigured-ignition",
Short: "Generates an agent ignition that excludes cluster configuration",
Args: cobra.ExactArgs(0),
Hidden: true,
},
assets: []asset.WritableAsset{
&image.UnconfiguredIgnition{},
},
}
agentCertificatesTarget = target{
name: "Agent create certificates",
command: &cobra.Command{
Use: "certificates",
Short: "Generates the tls certificates that can be used to create kubeconfig, along with kubeadmin-password",
Args: cobra.ExactArgs(0),
Hidden: true,
},
assets: []asset.WritableAsset{
&tls.KubeAPIServerLBSignerCertKey{},
&tls.KubeAPIServerLocalhostSignerCertKey{},
&tls.KubeAPIServerServiceNetworkSignerCertKey{},
&tls.AdminKubeConfigSignerCertKey{},
&image.AgentPassword{},
},
}
agentTargets = []target{agentConfigTarget, agentManifestsTarget, agentImageTarget, agentPXEFilesTarget, agentConfigImageTarget, agentUnconfiguredIgnitionTarget, agentCertificatesTarget}
)
func newAgentCreateCmd(ctx context.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "Commands for generating agent installation artifacts",
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}
for _, t := range agentTargets {
t.command.Args = cobra.ExactArgs(0)
t.command.Run = runTargetCmd(ctx, t.assets...)
cmd.AddCommand(t.command)
}
return cmd
}
func newAgentGraphCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "graph",
Short: "Outputs the internal dependency graph for the agent-based installer",
Long: "",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return runGraphCmd(cmd, args, agentTargets)
},
}
cmd.PersistentFlags().StringVar(&graphOpts.outputFile, "output-file", "", "file where the graph is written, if empty prints the graph to Stdout.")
return cmd
}