Skip to content

Commit

Permalink
Delete classic mode install/uninstall/upgrade commands
Browse files Browse the repository at this point in the history
Ref: #2327

Signed-off-by: Michi Mutsuzaki <[email protected]>
  • Loading branch information
michi-covalent committed Feb 27, 2024
1 parent fd298d6 commit e435b47
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 2,026 deletions.
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ binary releases.
| [v0.15.23](https://github.com/cilium/cilium-cli/releases/tag/v0.15.23) | Yes | Cilium 1.14 and newer |
| [v0.14.8](https://github.com/cilium/cilium-cli/releases/tag/v0.14.8) | Yes | Cilium 1.13 |

Please see [`helm` installation mode](#helm-installation-mode) section
regarding our plan to migrate to the new `helm` installation mode and deprecate
the current implementation.

## Capabilities

### Install Cilium
Expand Down Expand Up @@ -346,27 +342,6 @@ Install a Cilium in a cluster and enable encryption with IPsec
🚀 Creating Operator Deployment...
⌛ Waiting for Cilium to be installed...

## `helm` installation mode

`cilium-cli` v0.14 introduces a new `helm` installation mode. In the current installation mode
(we now call it `classic` mode), `cilium-cli` directly calls Kubernetes APIs to manage resources
related to Cilium. In the new `helm` mode, `cilium-cli` delegates all the installation state
management to Helm. This enables you to use `cilium-cli` and `helm` interchangeably to manage your
Cilium installation, while taking advantage of `cilium-cli`'s advanced features such as Cilium
configuration auto-detection.

In `cilium-cli` v0.15, the `helm` mode is the default installation mode, and the `classic` mode is
deprecated. To use the `classic` mode, set `CILIUM_CLI_MODE` environment variable to `classic`:

export CILIUM_CLI_MODE=classic

> **Warnings**
> - The `classic` installation mode will be removed after v0.15 release.
> - Cilium CLI does not support converting `classic` mode installations to
> `helm` mode installations and vice versa.
> - Cilium CLI does not support running commands in `helm` mode against classic
> mode installations.
### Examples

#### `install` examples
Expand Down
45 changes: 1 addition & 44 deletions install/autodetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ package install
import (
"context"
"fmt"
"regexp"
"strconv"
"strings"

"github.com/cilium/cilium-cli/internal/utils"
"github.com/cilium/cilium-cli/k8s"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -30,8 +28,6 @@ var (
&kindVersionValidation{},
},
}

clusterNameValidation = regexp.MustCompile(`^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])$`)
)

func (p Parameters) checkDisabled(name string) bool {
Expand All @@ -43,14 +39,6 @@ func (p Parameters) checkDisabled(name string) bool {
return false
}

func (k *K8sUninstaller) autodetect(ctx context.Context) {
k.flavor = k.client.AutodetectFlavor(ctx)

if k.flavor.Kind != k8s.KindUnknown {
k.Log("🔮 Auto-detected Kubernetes kind: %s", k.flavor.Kind)
}
}

func (k *K8sInstaller) detectDatapathMode() error {
if k.params.DatapathMode != "" {
k.Log("ℹ️ Custom datapath mode: %s", k.params.DatapathMode)
Expand Down Expand Up @@ -169,43 +157,12 @@ func (k *K8sInstaller) autodetectAndValidate(ctx context.Context, helmValues map
return err
}

// TODO: remove when removing "ipam" flag (marked as deprecated), kept for
// backwards compatibility
if k.params.IPAM != "" {
k.Log("ℹ️ Custom IPAM mode: %s", k.params.IPAM)
}

if !utils.IsInHelmMode() {
if strings.Contains(k.params.ClusterName, ".") {
k.Log("❌ Cluster name %q cannot contain dots", k.params.ClusterName)
return fmt.Errorf("invalid cluster name, dots are not allowed")
}

if !clusterNameValidation.MatchString(k.params.ClusterName) {
k.Log("❌ Cluster name %q is not valid, must match regular expression: %s", k.params.ClusterName, clusterNameValidation)
return fmt.Errorf("invalid cluster name")
}
}

switch k.params.Encryption {
case encryptionDisabled,
encryptionIPsec,
encryptionWireguard,
encryptionUnspecified:
// nothing to do for valid values
default:
k.Log("❌ Invalid encryption mode: %q", k.params.Encryption)
return fmt.Errorf("invalid encryption mode")
}

k.autodetectKubeProxy(ctx)
return k.autoEnableBPFMasq()
}

func (k *K8sInstaller) autodetectKubeProxy(ctx context.Context) error {
if k.params.UserSetKubeProxyReplacement {
return nil
} else if k.flavor.Kind == k8s.KindK3s {
if k.flavor.Kind == k8s.KindK3s {
return nil
}

Expand Down
53 changes: 1 addition & 52 deletions install/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
package install

import (
"context"
"encoding/json"
"fmt"

"github.com/cilium/cilium/pkg/versioncheck"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/getter"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/cilium/cilium-cli/defaults"
"github.com/cilium/cilium-cli/internal/utils"
yamlUtils "github.com/cilium/cilium-cli/utils/yaml"
)

type accountInfo struct {
Expand Down Expand Up @@ -138,12 +130,7 @@ func (k *K8sInstaller) azureRetrieveAKSClusterInfo() error {
return err
}
if k.params.Azure.ResourceGroupName == "" {
var requiredFlagsNote string
if utils.IsInHelmMode() {
requiredFlagsNote = "azure.resourceGroup Helm value"
} else {
requiredFlagsNote = "--azure-resource-group or azure.resourceGroup Helm value"
}
requiredFlagsNote := "azure.resourceGroup Helm value"
k.Log("❌ Azure resource group is required, please specify %s", requiredFlagsNote)
return fmt.Errorf("missing Azure resource group name")
}
Expand Down Expand Up @@ -233,41 +220,3 @@ func (k *K8sInstaller) azExec(args ...string) ([]byte, error) {
args = append(args, "--output", "json", "--only-show-errors")
return k.Exec("az", args...)
}

func (k *K8sInstaller) createAKSSecrets(ctx context.Context) error {
// Check if secret already exists and reuse it
_, err := k.client.GetSecret(ctx, k.params.Namespace, defaults.AKSSecretName, metav1.GetOptions{})
if err == nil {
k.Log("🔑 Found existing AKS secret %s", defaults.AKSSecretName)
return nil
}

var (
secretFileName string
)

switch {
case versioncheck.MustCompile(">=1.12.0")(k.chartVersion):
secretFileName = "templates/cilium-operator/secret.yaml"
default:
return fmt.Errorf("cilium version unsupported %s", k.chartVersion)
}

secretFile := k.manifests[secretFileName]

var secret corev1.Secret
yamlUtils.MustUnmarshal([]byte(secretFile), &secret)

k.Log("🔑 Generated AKS secret %s", defaults.AKSSecretName)
_, err = k.client.CreateSecret(ctx, k.params.Namespace, &secret, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("unable to create AKS secret %s/%s: %w", k.params.Namespace, defaults.AKSSecretName, err)
}
k.pushRollbackStep(func(ctx context.Context) {
if err := k.client.DeleteSecret(ctx, k.params.Namespace, defaults.AKSSecretName, metav1.DeleteOptions{}); err != nil {
k.Log("Cannot delete %s Secret: %s", defaults.AKSSecretName, err)
}
})

return nil
}
8 changes: 0 additions & 8 deletions install/bgp.go

This file was deleted.

131 changes: 0 additions & 131 deletions install/certs.go

This file was deleted.

60 changes: 0 additions & 60 deletions install/encryption.go

This file was deleted.

Loading

0 comments on commit e435b47

Please sign in to comment.