-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add workaround for Minikube storage provisioning bug #752
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import * as commandExists from 'command-exists' | |
import * as execa from 'execa' | ||
import * as Listr from 'listr' | ||
|
||
import { KubeHelper } from '../../api/kube' | ||
import { VersionHelper } from '../../api/version' | ||
|
||
import { CommonPlatformTasks } from './common-platform-tasks' | ||
|
@@ -22,6 +23,7 @@ export class MinikubeTasks { | |
* Returns tasks list which perform preflight platform checks. | ||
*/ | ||
preflightCheckTasks(flags: any, command: Command): Listr { | ||
const kube = new KubeHelper(flags) | ||
return new Listr([ | ||
{ | ||
title: 'Verify if kubectl is installed', | ||
|
@@ -79,6 +81,49 @@ export class MinikubeTasks { | |
task.title = `${task.title}...${flags.domain}.` | ||
} | ||
}, | ||
{ | ||
title: 'Checking minikube version', | ||
task: async (ctx: any, task: any) => { | ||
const version = await this.getMinikbeVersion() | ||
const versionComponents = version.split('.') | ||
ctx.minikubeVersionMajor = parseInt(versionComponents[0], 10) | ||
ctx.minikubeVersionMinor = parseInt(versionComponents[1], 10) | ||
ctx.minikubeVersionPatch = parseInt(versionComponents[2], 10) | ||
|
||
task.title = `${task.title}... ${version}` | ||
} | ||
}, | ||
{ | ||
// Starting from Minikube 1.9 there is a bug with storage provisioner which prevents Che from successful deployment. | ||
// For more details see https://github.com/kubernetes/minikube/issues/7218 | ||
// To workaround the bug, it is required to patch storage provisioner as well as its permissions. | ||
title: 'Patch minikube storage', | ||
enabled: ctx => ctx.minikubeVersionMajor && ctx.minikubeVersionMinor && | ||
ctx.minikubeVersionMajor === 1 && ctx.minikubeVersionMinor >= 9 && ctx.minikubeVersionMinor <= 11, | ||
task: async (_ctx: any, task: any) => { | ||
// Patch storage provisioner pod to the latest version | ||
const storageProvisionerImagePatch = { | ||
apiVersion: 'v1', | ||
kind: 'Pod', | ||
spec: { | ||
containers: [ | ||
{ name: 'storage-provisioner', image: 'gcr.io/k8s-minikube/storage-provisioner:latest' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I will use digest as there is no tag (if don't count |
||
] | ||
} | ||
} | ||
if (! await kube.patchNamespacedPod('storage-provisioner', 'kube-system', storageProvisionerImagePatch)) { | ||
throw new Error('Failed to patch storage provisioner image') | ||
} | ||
|
||
// Set required permissions for cluster role of persistent volume provisioner | ||
if (! await kube.addClusterRoleRule('system:persistent-volume-provisioner', | ||
[''], ['endpoints'], ['get', 'list', 'watch', 'create', 'patch', 'update'])) { | ||
throw new Error('Failed to patch permissions for persistent-volume-provisioner') | ||
} | ||
|
||
task.title = `${task.title}... done` | ||
} | ||
}, | ||
CommonPlatformTasks.getPingClusterTask(flags) | ||
], { renderer: flags['listr-renderer'] as any }) | ||
} | ||
|
@@ -106,4 +151,11 @@ export class MinikubeTasks { | |
return stdout | ||
} | ||
|
||
async getMinikbeVersion(): Promise<string> { | ||
const { stdout } = await execa('minikube', ['version'], { timeout: 10000 }) | ||
const versionLine = stdout.split('\n')[0] | ||
const versionString = versionLine.trim().split(' ')[2].substr(1) | ||
return versionString | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to check that the version is <= 11? I mean I would set the upper bound only when we know which version of minikube will contain the fix. Otherwise we will get a blocker as soon as 1.12 is out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is sort of a template when the bug is fixed. Seems there are some activity in the Minikube issue, so I hoped that it will be fixed soon. But agree, we'll add stop condition when Minikube fix arrives.