You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`mapkubeapis` is a Helm v2/v3 plugin which updates in-place Helm release metadata that contains deprecated or removed Kubernetes APIs to a new instance with supported Kubernetes APIs. Jump to [background to the issue](#background-to-the-issue) for more details on the problem space that the plugin solves.
8
+
`mapkubeapis` is a Helm v3 plugin which updates in-place Helm release metadata that contains deprecated or removed Kubernetes APIs to a new instance with supported Kubernetes APIs. Jump to [background to the issue](#background-to-the-issue) for more details on the problem space that the plugin solves.
9
9
10
-
> Note: Charts need to be updated also to supported Kubernetes APIs to avoid failure during deployment in a Kubernetes version. This is a separate task to the plugin.
10
+
> Note: Charts need to be updated also to supported Kubernetes APIs to avoid failure during deployment in a Kubernetes version. This is a separate task to the plugin.
11
11
12
12
## Prerequisite
13
13
14
14
- Helm client with `mapkubeapis` plugin installed on the same system
15
15
- Access to the cluster(s) that Helm manages. This access is similar to `kubectl` access using [kubeconfig files](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/).
16
16
The `--kubeconfig`, `--kube-context` and `--namespace` flags can be used to set the kubeconfig path, kube context and namespace context to override the environment configuration.
17
-
- If you try and upgrade a release with unsupported APIs then the upgrade will fail. This is ok in Helm v3 as it will not generate a failed release for Helm. However, Helm v2 does produce a failed release. This needs to be removed before running the plugin on the release. The command to remove the failed release version is: `kubectl delete configmap/secret <release_name>.v<latest_version_number> --namespace <tiller_namespace>`
17
+
- If you try and upgrade a release with unsupported APIs then the upgrade will fail. This is ok in Helm v3 as it will not generate a failed release for Helm.
18
18
- The plugin updates the lastest release version. The latest release version should be in a `deployed` state as you want to update a successful deployment. If it is not then you need to delete the latest release version. The command to remove a release version is:
--kube-context string name of the kubeconfig context to use
55
54
--kubeconfig string path to the kubeconfig file
56
55
--mapfile string path to the API mapping file (default "config/Map.yaml")
57
-
--namespace string namespace scope of the release. For Helm v2, this is the Tiller namespace (e.g. kube-system)
58
-
-s, --release-storage string for Helm v2 only - release storage type/object. It can be 'secrets' or 'configmaps'. This is only used with the 'tiller-out-cluster' flag (default "secrets")
59
-
--tiller-out-cluster for Helm v2 only - when Tiller is not running in the cluster e.g. Tillerless
2020/04/17 13:05:45 Release 'v2-oldapi' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions.
68
-
2020/04/17 13:05:45 Get release 'v2-oldapi' latest version.
69
-
2020/04/17 13:05:45 Check release 'v2-oldapi' for deprecated or removed APIs...
70
-
2020/04/17 13:05:45 Found deprecated or removed Kubernetes API:
2022/02/07 18:48:49 Release 'cluster-role-example' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions.
64
+
2022/02/07 18:48:49 Get release 'cluster-role-example' latest version.
65
+
2022/02/07 18:48:49 Check release 'cluster-role-example' for deprecated or removed APIs...
66
+
2022/02/07 18:48:49 Found 1 instances of deprecated or removed Kubernetes API:
67
+
"apiVersion: rbac.authorization.k8s.io/v1beta1
68
+
kind: ClusterRole
69
+
"
73
70
Supported API equivalent:
74
-
"apiVersion: apps/v1
75
-
kind: Deployment"
76
-
2020/04/17 13:05:45 Found deprecated or removed Kubernetes API:
77
-
"apiVersion: extensions/v1beta1
78
-
kind: Ingress"
71
+
"apiVersion: rbac.authorization.k8s.io/v1
72
+
kind: ClusterRole
73
+
"
74
+
2022/02/07 18:48:49 Found 1 instances of deprecated or removed Kubernetes API:
75
+
"apiVersion: rbac.authorization.k8s.io/v1beta1
76
+
kind: ClusterRoleBinding
77
+
"
79
78
Supported API equivalent:
80
-
"apiVersion: networking.k8s.io/v1beta1
81
-
kind: Ingress"
82
-
2020/04/17 13:05:45 Finished checking release 'v2-oldapi' for deprecated or removed APIs.
83
-
2020/04/17 13:05:45 Deprecated or removed APIs exist, updating release: v2-oldapi.
84
-
2020/04/17 13:05:45 Set status of release version 'v2-oldapi.v1' to 'superseded'.
85
-
2020/04/17 13:05:45 Release version 'v2-oldapi.v1' updated successfully.
86
-
2020/04/17 13:05:45 Add release version 'v2-oldapi.v2' with updated supported APIs.
87
-
2020/04/17 13:05:45 Release version 'v2-oldapi.v2' added successfully.
88
-
2020/04/17 13:05:45 Release 'v2-oldapi' with deprecated or removed APIs updated successfully to new version.
89
-
2020/04/17 13:05:45 Map of release 'v2-oldapi' deprecated or removed APIs to supported versions, completed successfully.
79
+
"apiVersion: rbac.authorization.k8s.io/v1
80
+
kind: ClusterRoleBinding
81
+
"
82
+
2022/02/07 18:48:49 Finished checking release 'cluster-role-example' for deprecated or removed APIs.
83
+
2022/02/07 18:48:49 Deprecated or removed APIs exist, updating release: cluster-role-example.
84
+
2022/02/07 18:48:49 Set status of release version 'cluster-role-example.v1' to 'superseded'.
85
+
2022/02/07 18:48:49 Release version 'cluster-role-example.v1' updated successfully.
86
+
2022/02/07 18:48:49 Add release version 'cluster-role-example.v2' with updated supported APIs.
87
+
2022/02/07 18:48:49 Release version 'cluster-role-example.v2' added successfully.
88
+
2022/02/07 18:48:49 Release 'cluster-role-example' with deprecated or removed APIs updated successfully to new version.
89
+
2022/02/07 18:48:49 Map of release 'cluster-role-example' deprecated or removed APIs to supported versions, completed successfully.
90
90
```
91
+
91
92
## API Mapping
92
93
93
94
The mapping information of deprecated or removed APIs to supported APIs is configured in the [Map.yaml](https://github.com/helm/helm-mapkubeapis/blob/master/config/Map.yaml) file. The file is a list of entries similar to the following:
@@ -102,29 +103,32 @@ The mapping information of deprecated or removed APIs to supported APIs is confi
102
103
The plugin when performing update of a Helm release metadata first loads the map file from the `config` directory where the plugin is run from. If the map file is a different name or in a different location, you can use the `--mapfile` flag to specify the different mapping file.
103
104
104
105
The OOTB mapping file is configured as follows:
106
+
105
107
- The search and replace strings are in order with `apiVersion` first and then `kind`. This should be changed if the Helm release metadata is rendered with different search/replace string.
106
108
- The strings contain UNIX/Linux line feeds. This means that `\n` is used to signify line separation between properties in the strings. This should be changed if the Helm release metadata is rendered in Windows or Mac.
107
109
- Each mapping contains the Kubernetes version that the API is deprecated and removed in. This information is important as the plugin checks that the deprecated version (uses removed if deprecated unset) is later than the Kubernetes version that it is running against. If it is then no mapping occurs for this API as it not yet deprecated in this Kubernetes version and hence the new API is not yet supported. Otherwise, the mapping can proceed.
108
110
109
111
> Note: The Helm release metadata can be checked by following the steps in:
110
-
- Helm v2: [Updating API Versions of a Release Manifest](https://github.com/helm/helm/blob/dev-v2/docs/kubernetes_apis.md#updating-api-versions-of-a-release-manifest)
111
112
- Helm v3: [Updating API Versions of a Release Manifest](https://helm.sh/docs/topics/kubernetes_apis/#updating-api-versions-of-a-release-manifest)
112
113
113
114
## Background to the issue
114
115
115
116
For details on the background to this issue, it is recommended to read the docs appropriate to your Helm version. The docs can be accessed as follows:
The Helm documentation describes the problem when Helm releases that are already deployed with APIs that are no longer supported. If the Kubernetes cluster (containing such releases) is updated to a version where the APIs are removed, then Helm becomes unable to manage such releases anymore. It does not matter if the chart being passed in the upgrade contains the supported API versions or not.
120
120
121
121
This is what the `mapkubeapis` plugin resolves. It fixes the issue by mapping releases which contain deprecated or removed Kubernetes APIs to supported APIs. This is performed inline in the release metadata where the existing release is `superseded` and a new release (metadata only) is added. The deployed Kubernetes resources are updated automatically by Kubernetes during upgrade of its version. Once this operation is completed, you can then upgrade using the chart with supported APIs.
122
122
123
+
## Helm v2 Support
124
+
125
+
Helm [v2.17.0](https://github.com/helm/helm/releases/tag/v2.17.0) was the final release of Helm v2 in October 2020. Helm v2 is unsupported since November 2020, as detailed in [Helm 2 and the Charts Project Are Now Unsupported](https://helm.sh/blog/helm-2-becomes-unsupported/). `mapkubeapis` Helm v2 support finished in [release v0.2.0](https://github.com/helm/helm-mapkubeapis/releases/tag/v0.2.0).
126
+
123
127
## Developer (From Source) Install
124
128
125
129
If you would like to handle the build yourself, this is the recommended way to do it.
126
130
127
-
You must first have [Go v1.13+](http://golang.org) installed, and then you run:
131
+
You must first have [Go v1.17+](http://golang.org) installed, and then you run:
Copy file name to clipboardexpand all lines: cmd/mapkubeapis/environment.go
+6-12
Original file line number
Diff line number
Diff line change
@@ -22,14 +22,11 @@ import (
22
22
23
23
// EnvSettings defined settings
24
24
typeEnvSettingsstruct {
25
-
DryRunbool
26
-
KubeConfigFilestring
27
-
KubeContextstring
28
-
MapFilestring
29
-
Namespacestring
30
-
RunV2bool
31
-
StorageTypestring
32
-
TillerOutClusterbool
25
+
DryRunbool
26
+
KubeConfigFilestring
27
+
KubeContextstring
28
+
MapFilestring
29
+
Namespacestring
33
30
}
34
31
35
32
// New returns default env settings
@@ -49,8 +46,5 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
49
46
fs.StringVar(&s.KubeConfigFile, "kubeconfig", "", "path to the kubeconfig file")
50
47
fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use")
51
48
fs.StringVar(&s.MapFile, "mapfile", s.MapFile, "path to the API mapping file")
52
-
fs.StringVar(&s.Namespace, "namespace", s.Namespace, "namespace scope of the release. For Helm v2, this is the Tiller namespace e.g. kube-system")
53
-
fs.BoolVar(&s.RunV2, "v2", false, "run for Helm v2 release. The default is Helm v3.")
54
-
fs.BoolVar(&s.TillerOutCluster, "tiller-out-cluster", false, "for Helm v2 only - when Tiller is not running in the cluster e.g. Tillerless")
55
-
fs.StringVarP(&s.StorageType, "release-storage", "s", "secrets", "for Helm v2 only - release storage type/object. It can be 'secrets' or 'configmaps'. This is only used with the 'tiller-out-cluster' flag")
49
+
fs.StringVar(&s.Namespace, "namespace", s.Namespace, "namespace scope of the release")
0 commit comments