Windows support

This commit is contained in:
n313893254 2018-06-01 15:46:47 +08:00
parent f9e86fad1e
commit 64be404fbb
4 changed files with 149 additions and 10 deletions

View File

@ -98,6 +98,9 @@ export default InputTextFile.extend(ClusterDriver, {
worker: true, worker: true,
defaultDockerRootDir: null, defaultDockerRootDir: null,
windowsEnable: null,
isLinux: true,
windowsSupport: false,
isNew: equal('mode', 'new'), isNew: equal('mode', 'new'),
isEdit: equal('mode', 'edit'), isEdit: equal('mode', 'edit'),
notView: or('isNew', 'isEdit'), notView: or('isNew', 'isEdit'),
@ -145,6 +148,16 @@ export default InputTextFile.extend(ClusterDriver, {
let defaultCluster = globalStore.createRecord({ type: 'cluster' }) let defaultCluster = globalStore.createRecord({ type: 'cluster' })
set(this, 'defaultDockerRootDir', defaultCluster.dockerRootDir) set(this, 'defaultDockerRootDir', defaultCluster.dockerRootDir)
if (!get(this, 'isEdit')) {
this.windowsSupportChange()
}
if (get(this, 'isEdit')) {
if (get(this, 'config.network.options.flannel_backend_type')) {
set(this, 'windowsSupport', true)
}
}
}); });
}, },
@ -186,8 +199,9 @@ export default InputTextFile.extend(ClusterDriver, {
strategy: 'x509', strategy: 'x509',
}), }),
network: globalStore.createRecord({ network: globalStore.createRecord({
type: 'networkConfig', type: 'networkConfig',
plugin: 'canal', plugin: 'canal',
options: { flannel_backend_type: null, },
}), }),
ingress: globalStore.createRecord({ ingress: globalStore.createRecord({
type: 'ingressConfig', type: 'ingressConfig',
@ -231,6 +245,43 @@ export default InputTextFile.extend(ClusterDriver, {
} }
}), }),
windowsSupportChange: observer('windowsSupport', function() {
const windowsSupport = get(this, 'windowsSupport')
if (windowsSupport) {
let res = NETWORKCHOICES.filter((n) => n.value === 'flannel')
setProperties(this, {
networkContent: res,
'config.network.plugin': 'flannel',
'config.network.options.flannel_backend_type': 'host-gw',
})
} else {
setProperties(this, {
networkContent: NETWORKCHOICES,
'config.network.options.flannel_backend_type': null,
})
}
}),
isLinuxChanged: observer('isLinux', function() {
if (get(this, 'nodeWhich') !== 'custom') {
return
}
const mode = get(this, 'mode')
const isLinux = get(this, 'isLinux')
if (mode === 'edit') {
if (!isLinux) {
setProperties(this, {
controlplane: false,
etcd: false,
worker: true,
})
}
}
}),
versionChoices: computed('initialVersion', `settings.${ C.SETTING.VERSIONS_K8S }`, 'config.kubernetesVersion', function() { versionChoices: computed('initialVersion', `settings.${ C.SETTING.VERSIONS_K8S }`, 'config.kubernetesVersion', function() {
const versions = JSON.parse(get(this, `settings.${ C.SETTING.VERSIONS_K8S }`) || '{}'); const versions = JSON.parse(get(this, `settings.${ C.SETTING.VERSIONS_K8S }`) || '{}');
@ -296,7 +347,7 @@ export default InputTextFile.extend(ClusterDriver, {
return cur - orig; return cur - orig;
}), }),
command: computed('labels', 'token.nodeCommand', 'etcd', 'controlplane', 'worker', 'address', 'internalAddress', 'nodeName', function() { command: computed('labels', 'token.nodeCommand', 'token.windowsNodeCommand', 'etcd', 'controlplane', 'worker', 'address', 'internalAddress', 'nodeName', 'isLinux', function() {
let out = get(this, 'token.nodeCommand'); let out = get(this, 'token.nodeCommand');
if ( !out ) { if ( !out ) {
@ -333,6 +384,24 @@ export default InputTextFile.extend(ClusterDriver, {
out += ` --label ${ key }=${ labels[key] }`; out += ` --label ${ key }=${ labels[key] }`;
}); });
if (!get(this, 'isLinux')) {
out = get(this, 'token.windowsNodeCommand') || ''
out = out.replace('--isolation hyperv ', '')
let addressCmd = ''
if (address) {
addressCmd += ` -address ${ address }`
}
if (internalAddress) {
addressCmd += ` -internalAddress ${ internalAddress }`
}
if (addressCmd) {
out = out.replace(`; if($?)`, `${ addressCmd }; if($?)`)
}
}
return out; return out;
}), }),

View File

@ -35,6 +35,25 @@
</div> </div>
{{copy-to-clipboard tooltipText="" buttonText="copyToClipboard.tooltip" clipboardText=value class="with-clip"}} {{copy-to-clipboard tooltipText="" buttonText="copyToClipboard.tooltip" clipboardText=value class="with-clip"}}
{{else}} {{else}}
{{#if (eq nodeWhich 'custom')}}
<div class="row">
<div class="col span-4">
<label class="acc-label">{{t 'clusterNew.rke.windowsSupport.label'}}</label>
<div class="radio">
<label>
{{radio-button selection=windowsSupport value=false }}
{{t 'generic.disabled'}}
</label>
</div>
<div class="radio">
<label>
{{radio-button selection=windowsSupport value=true }}
{{t 'generic.enabled'}}
</label>
</div>
</div>
</div>
{{/if}}
<div class="row"> <div class="row">
<div class="col span-4"> <div class="col span-4">
<label class="acc-label">{{t 'clusterNew.rke.version.label'}}</label> <label class="acc-label">{{t 'clusterNew.rke.version.label'}}</label>
@ -48,7 +67,7 @@
<label class="acc-label">{{t 'clusterNew.rke.network.label'}}</label> <label class="acc-label">{{t 'clusterNew.rke.network.label'}}</label>
{{new-select {{new-select
classNames="form-control" classNames="form-control"
content=networkChoices content=networkContent
localizedLabel=true localizedLabel=true
value=cluster.rancherKubernetesEngineConfig.network.plugin value=cluster.rancherKubernetesEngineConfig.network.plugin
disabled=isEdit disabled=isEdit
@ -201,8 +220,35 @@
{{/if}} {{/if}}
{{#if (and isCustom (eq step 2)) }} {{#if (and isCustom (eq step 2)) }}
{{#accordion-list showExpandAll=false as |al expandFn|}} {{#accordion-list showExpandAll=false as |al expandFn|}}
{{#if windowsSupport}}
{{#accordion-list-item
title=(t 'clusterNew.rke.system.title')
detail=(t 'clusterNew.rke.system.detail')
expandOnInit=true
expandAll=al.expandAll
expand=(action expandFn)
}}
<div class="row">
<div class="col span-6 text-center mt-0 mb-0">
<div class="radio">
<label>
{{radio-button selection=isLinux value=true}}
Linux
</label>
</div>
</div>
<div class="col span-6 text-center mt-0 mb-0">
<div class="radio">
<label>
{{radio-button selection=isLinux value=false}}
Windows
</label>
</div>
</div>
</div>
{{/accordion-list-item}}
{{/if}}
{{#accordion-list-item {{#accordion-list-item
title=(t 'clusterNew.rke.role.pageheader') title=(t 'clusterNew.rke.role.pageheader')
detail=(t 'clusterNew.rke.info.text') detail=(t 'clusterNew.rke.info.text')
@ -225,13 +271,13 @@
<li> <li>
<div class="row"> <div class="row">
<div class="col span-4 text-center mt-0 mb-0"> <div class="col span-4 text-center mt-0 mb-0">
<label class="p-10 pl-30 pr-30">{{input type="checkbox" checked=etcd}} {{t 'clusterNew.rke.role.header.etcd'}}</label> <label class="p-10 pl-30 pr-30 {{unless isLinux 'text-muted'}}">{{input type="checkbox" checked=etcd disabled=(not isLinux) }} {{t 'clusterNew.rke.role.header.etcd'}}</label>
</div> </div>
<div class="col span-4 text-center mt-0 mb-0"> <div class="col span-4 text-center mt-0 mb-0">
<label class="p-10 pl-30 pr-30">{{input type="checkbox" checked=controlplane}} {{t 'clusterNew.rke.role.header.controlplane'}}</label> <label class="p-10 pl-30 pr-30 {{unless isLinux 'text-muted'}}">{{input type="checkbox" checked=controlplane disabled=(not isLinux) }} {{t 'clusterNew.rke.role.header.controlplane'}}</label>
</div> </div>
<div class="col span-4 text-center mt-0 mb-0"> <div class="col span-4 text-center mt-0 mb-0">
<label class="p-10 pl-30 pr-30">{{input type="checkbox" checked=worker}} {{t 'clusterNew.rke.role.header.worker'}}</label> <label class="p-10 pl-30 pr-30">{{input type="checkbox" checked=worker disabled=(not isLinux) }} {{t 'clusterNew.rke.role.header.worker'}}</label>
</div> </div>
</div> </div>
{{#advanced-section advanced=advanced}} {{#advanced-section advanced=advanced}}
@ -343,7 +389,7 @@
</ul> </ul>
</li> </li>
<li> <li>
{{t 'clusterNew.rke.command.instructions'}} {{t (if isLinux 'clusterNew.rke.command.instructions' 'clusterNew.rke.command.winInstructions') htmlSafe=true}}
{{!-- <p class="help-block">{{t 'clusterNew.rke.labels.detail'}}</p> --}} {{!-- <p class="help-block">{{t 'clusterNew.rke.labels.detail'}}</p> --}}
<ul class="list-unstyled"> <ul class="list-unstyled">
<li> <li>
@ -364,6 +410,14 @@
</section> </section>
{{/accordion-list-item}} {{/accordion-list-item}}
{{#if isLinux}}
{{form-user-labels
setLabels=(action 'setLabels')
expandAll=al.expandAll
expand=(action expandFn)
detailKey="formUserLabels.nodeDetail"
}}
{{/if}}
{{/accordion-list}} {{/accordion-list}}
{{#if newNodeCount}} {{#if newNodeCount}}

View File

@ -90,7 +90,14 @@ export default Component.extend(ThrottledResize, {
url = `${ scheme }${ window.location.host }/k8s/clusters/${ clusterId }/api/v1/namespaces/${ namespaceId }/pods/${ podName }/exec`; url = `${ scheme }${ window.location.host }/k8s/clusters/${ clusterId }/api/v1/namespaces/${ namespaceId }/pods/${ podName }/exec`;
url += `?container=${ encodeURIComponent(containerName) }&stdout=1&stdin=1&stderr=1&tty=1`; url += `?container=${ encodeURIComponent(containerName) }&stdout=1&stdin=1&stderr=1&tty=1`;
const command = get(instance, 'command') || DEFAULT_COMMAND; let command = get(instance, 'command') || DEFAULT_COMMAND;
const { node } = instance || {}
const system = node.info && node.info.os && node.info.os.operatingSystem || ''
if (system.startsWith('Windows')) {
command = ['cmd']
}
command.forEach((c) => { command.forEach((c) => {
url += `&command=${ encodeURIComponent(c) }`; url += `&command=${ encodeURIComponent(c) }`;

View File

@ -2078,6 +2078,7 @@ clusterNew:
text: Editing node options will update the command you will run on your existing machines text: Editing node options will update the command you will run on your existing machines
command: command:
instructions: 'Run this command on one or more existing machines already running a supported version of Docker.' instructions: 'Run this command on one or more existing machines already running a supported version of Docker.'
winInstructions: 'Run this command in <code>CMD</code> on one or more existing machines already running a supported version of Docker and windows server version more than <code style="color: #27AA5E; background: rgba(39, 170, 94, 0.15);">1803</code>.'
auth: auth:
label: Auth Provider label: Auth Provider
x509: x509 x509: x509
@ -2099,6 +2100,8 @@ clusterNew:
calico: calico:
cloudProvider: cloudProvider:
label: Cloud Provider label: Cloud Provider
type:
info: Only support "host-gw" backend
ingress: ingress:
label: Nginx Ingress label: Nginx Ingress
monitoring: monitoring:
@ -2159,6 +2162,12 @@ clusterNew:
worker: Please select at least one node to use as a worker. worker: Please select at least one node to use as a worker.
dockerRootDir: dockerRootDir:
placeholder: Default directory is {dir}. placeholder: Default directory is {dir}.
system:
title: Node Operating System
detail: The OS of the node which will be added into the cluster
windowsSupport:
label: Windows Support (Experimental)
disabled: Not support {plugin} network provider.
custom: custom:
label: Custom label: Custom
shortLabel: Custom shortLabel: Custom