mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
fix: rename image_registry to registry (#2635)
Signed-off-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
parent
a306bd6bca
commit
2acae88739
|
|
@ -11,9 +11,8 @@
|
|||
- include_tasks: uninstall_cridockerd.yaml
|
||||
when:
|
||||
- .cri.container_manager | eq "docker"
|
||||
- .kube_version | semverCompare ">=v1.24.0"
|
||||
- .cridockerd_version | empty | not
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete cri residue files
|
||||
command: |
|
||||
rm -f /usr/local/bin/crictl
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
rm -rf /etc/systemd/system/containerd.service*
|
||||
systemctl daemon-reload
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete containerd residue files
|
||||
command: |
|
||||
rm -rf {{ .cri.containerd.data_root }}
|
||||
rm -rf /etc/containerd
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
rm -rf /etc/systemd/system/cri-dockerd.service*
|
||||
systemctl daemon-reload
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete cri-dockerd residue files
|
||||
command: |
|
||||
rm -rf /etc/cri-dockerd
|
||||
rm -f /usr/local/bin/cri-dockerd
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
- name: Uninstall containerd
|
||||
include_tasks: uninstall_containerd.yaml
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete docker residue files
|
||||
command: |
|
||||
rm -rf {{ .cri.docker.data_root }}
|
||||
rm -rf /etc/docker
|
||||
|
|
|
|||
|
|
@ -15,3 +15,6 @@
|
|||
|
||||
- include_tasks: nfs.yaml
|
||||
tags: ["nfs"]
|
||||
|
||||
- include_tasks: image_registry.yaml
|
||||
tags: ["image_registry"]
|
||||
|
|
|
|||
|
|
@ -7,13 +7,12 @@
|
|||
include_tasks: uninstall_docker.yaml
|
||||
when: .cri.container_manager | eq "docker"
|
||||
|
||||
# install cridockerd
|
||||
# uninstall cridockerd
|
||||
- include_tasks: uninstall_cridockerd.yaml
|
||||
when:
|
||||
- .cri.container_manager | eq "docker"
|
||||
- .kube_version | semverCompare ">=v1.24.0"
|
||||
- .cridockerd_version | empty | not
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete cri residue files
|
||||
command: |
|
||||
rm -f /usr/local/bin/crictl
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
rm -rf /etc/systemd/system/containerd.service*
|
||||
systemctl daemon-reload
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete containerd residue files
|
||||
command: |
|
||||
rm -rf {{ .cri.containerd.data_root }}
|
||||
rm -rf /etc/containerd
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
rm -rf /etc/systemd/system/cri-dockerd.service*
|
||||
systemctl daemon-reload
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete cri-dockerd residue files
|
||||
command: |
|
||||
rm -rf /etc/cri-dockerd
|
||||
rm -f /usr/local/bin/cri-dockerd
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
- name: Uninstall containerd
|
||||
include_tasks: uninstall_containerd.yaml
|
||||
|
||||
- name: Delete residue files
|
||||
- name: Delete docker residue files
|
||||
command: |
|
||||
rm -rf {{ .cri.docker.data_root }}
|
||||
rm -rf /etc/docker
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func NewDeleteCommand() *cobra.Command {
|
|||
// Add subcommands for cluster, nodes, and image registry deletion
|
||||
cmd.AddCommand(newDeleteClusterCommand())
|
||||
cmd.AddCommand(newDeleteNodesCommand())
|
||||
cmd.AddCommand(newDeleteImageRegistryCommand())
|
||||
cmd.AddCommand(newDeleteRegistryCommand())
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
@ -108,18 +108,18 @@ func newDeleteNodesCommand() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// newDeleteImageRegistryCommand creates a new command for deleting the image registry created by kubekey.
|
||||
// newDeleteRegistryCommand creates a new command for deleting the image registry created by kubekey.
|
||||
// It uses the delete_image_registry.yaml playbook to remove the image registry and optionally its container runtime.
|
||||
func newDeleteImageRegistryCommand() *cobra.Command {
|
||||
func newDeleteRegistryCommand() *cobra.Command {
|
||||
// Initialize options for deleting the image registry
|
||||
o := builtin.NewDeleteImageRegistryOptions()
|
||||
o := builtin.NewDeleteRegistryOptions()
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "image_registry",
|
||||
Short: "Delete a image_registry which create by kubekey.",
|
||||
Use: "registry",
|
||||
Short: "Delete a image registry which create by kubekey.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// Complete the configuration and create a playbook for deleting the image registry
|
||||
playbook, err := o.Complete(cmd, []string{"playbooks/delete_image_registry.yaml"})
|
||||
playbook, err := o.Complete(cmd, []string{"playbooks/delete_registry.yaml"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,24 +218,14 @@ func (o *DeleteNodesOptions) completeConfig(nodes []string) error {
|
|||
}
|
||||
|
||||
// ======================================================================================
|
||||
// delete image_registry
|
||||
// delete registry
|
||||
// ======================================================================================
|
||||
|
||||
// NewDeleteImageRegistryOptions creates a new DeleteImageRegistryOptions with default values
|
||||
func NewDeleteImageRegistryOptions() *DeleteImageRegistryOptions {
|
||||
// NewDeleteRegistryOptions creates a new DeleteRegistryOptions with default values
|
||||
func NewDeleteRegistryOptions() *DeleteRegistryOptions {
|
||||
// set default value for DeleteImageRegistryOptions
|
||||
o := &DeleteImageRegistryOptions{
|
||||
o := &DeleteRegistryOptions{
|
||||
CommonOptions: options.NewCommonOptions(),
|
||||
Kubernetes: defaultKubeVersion,
|
||||
}
|
||||
// Set the function to get the config for the specified Kubernetes version
|
||||
o.CommonOptions.GetConfigFunc = func() (*kkcorev1.Config, error) {
|
||||
data, err := getConfig(o.Kubernetes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config := &kkcorev1.Config{}
|
||||
return config, errors.Wrapf(yaml.Unmarshal(data, config), "failed to unmarshal local configFile for kube_version: %q.", o.Kubernetes)
|
||||
}
|
||||
// Set the function to get the inventory
|
||||
o.CommonOptions.GetInventoryFunc = getInventory
|
||||
|
|
@ -243,25 +233,20 @@ func NewDeleteImageRegistryOptions() *DeleteImageRegistryOptions {
|
|||
return o
|
||||
}
|
||||
|
||||
// DeleteImageRegistryOptions contains options for deleting an image_registry created by kubekey
|
||||
type DeleteImageRegistryOptions struct {
|
||||
// DeleteRegistryOptions contains options for deleting an image_registry created by kubekey
|
||||
type DeleteRegistryOptions struct {
|
||||
options.CommonOptions
|
||||
// Kubernetes version which the cluster will install.
|
||||
Kubernetes string
|
||||
}
|
||||
|
||||
// Flags returns the flag sets for DeleteImageRegistryOptions
|
||||
func (o *DeleteImageRegistryOptions) Flags() cliflag.NamedFlagSets {
|
||||
func (o *DeleteRegistryOptions) Flags() cliflag.NamedFlagSets {
|
||||
fss := o.CommonOptions.Flags()
|
||||
kfs := fss.FlagSet("config")
|
||||
// Add a flag for specifying the Kubernetes version
|
||||
kfs.StringVar(&o.Kubernetes, "with-kubernetes", o.Kubernetes, fmt.Sprintf("Specify a supported version of kubernetes. default is %s", o.Kubernetes))
|
||||
|
||||
return fss
|
||||
}
|
||||
|
||||
// Complete validates and completes the DeleteImageRegistryOptions configuration
|
||||
func (o *DeleteImageRegistryOptions) Complete(cmd *cobra.Command, args []string) (*kkcorev1.Playbook, error) {
|
||||
func (o *DeleteRegistryOptions) Complete(cmd *cobra.Command, args []string) (*kkcorev1.Playbook, error) {
|
||||
// Initialize playbook metadata for deleting image registry
|
||||
playbook := &kkcorev1.Playbook{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -291,17 +276,5 @@ func (o *DeleteImageRegistryOptions) Complete(cmd *cobra.Command, args []string)
|
|||
}
|
||||
|
||||
// Complete config specific to delete image registry
|
||||
return playbook, o.completeConfig()
|
||||
}
|
||||
|
||||
// completeConfig updates the configuration with container manager settings
|
||||
func (o *DeleteImageRegistryOptions) completeConfig() error {
|
||||
// If kube_version is not set in config, set it to the specified Kubernetes version
|
||||
if _, ok, _ := unstructured.NestedFieldNoCopy(o.CommonOptions.Config.Value(), "kube_version"); !ok {
|
||||
if err := unstructured.SetNestedField(o.CommonOptions.Config.Value(), o.Kubernetes, "kube_version"); err != nil {
|
||||
return errors.Wrapf(err, "failed to set %q to config", "kube_version")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return playbook, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ func (e *taskExecutor) Exec(ctx context.Context) error {
|
|||
// runTaskLoop runs a task in a loop until it completes or times out.
|
||||
// It periodically reconciles the task status and executes the task when it enters the running phase.
|
||||
func (e *taskExecutor) runTaskLoop(ctx context.Context) error {
|
||||
klog.V(5).InfoS("begin run task", "task", ctrlclient.ObjectKeyFromObject(e.task))
|
||||
defer klog.V(5).InfoS("end run task", "task", ctrlclient.ObjectKeyFromObject(e.task))
|
||||
klog.V(3).InfoS("begin run task", "task", ctrlclient.ObjectKeyFromObject(e.task))
|
||||
defer klog.V(3).InfoS("end run task", "task", ctrlclient.ObjectKeyFromObject(e.task))
|
||||
|
||||
// Add role prefix to log output if role annotation exists
|
||||
var roleLog string
|
||||
|
|
|
|||
Loading…
Reference in New Issue