Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ export default Resource.extend(Grafana, ResourceUsage, {
.filter((s) => !(s.conditions || []).any((c) => c.status === 'True'));
}),

masterNodes: computed('nodes.@each.{state,labels}', function() {
return (this.nodes || []).filter((node) => node.labels && node.labels[C.NODES.MASTER_NODE]);
}),

inactiveNodes: computed('nodes.@each.state', function() {
return (get(this, 'nodes') || []).filter( (n) => C.ACTIVEISH_STATES.indexOf(get(n, 'state')) === -1 );
}),
Expand Down
30 changes: 30 additions & 0 deletions app/models/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,36 @@ var Node = Resource.extend(Grafana, StateCounts, ResourceUsage, {
return taints.some((taint) => UNSCHEDULABLE_KEYS.includes(taint.key) && UNSCHEDULABLE_EFFECTS.includes(taint.effect));
}),

isK3sNode: computed('labels', function() {
const labels = get(this, 'labels') || {};

return Object.prototype.hasOwnProperty.call(labels, C.LABEL.NODE_INSTANCE_TYPE);
}),

k3sNodeArgs: computed('annotations', function() {
const { annotations } = this;
const nodeArgs = annotations[C.LABEL.K3S_NODE_ARGS] ? JSON.parse(annotations[C.LABEL.K3S_NODE_ARGS]) : [];

return nodeArgs.join(' ');
}),

k3sNodeEnvVar: computed('annotations', function() {
const { annotations } = this;
const nodeEnv = annotations[C.LABEL.K3S_NODE_ENV] ? JSON.parse(annotations[C.LABEL.K3S_NODE_ENV]) : {};
const nodeEnvArr = [];

Object.keys(nodeEnv).forEach((envKey) => {
const out = {
key: envKey,
value: nodeEnv[envKey]
};

nodeEnvArr.push(out)
})

return nodeEnvArr;
}),

osBlurb: computed('info.os.operatingSystem', function() {
var out = get(this, 'info.os.operatingSystem') || '';

Expand Down
7 changes: 5 additions & 2 deletions lib/monitoring/addon/components/node-dashboard/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { inject as service } from '@ember/service';
import layout from './template';

export default Component.extend({
scope: service(),
scope: service(),
layout,
model: null,
model: null,
sortBy: 'key',
descending: false,

isK3sNode: alias('model.node.isK3sNode'),
monitoringEnabled: alias('scope.currentCluster.enableClusterMonitoring'),
isMonitoringReady: alias('scope.currentCluster.isMonitoringReady'),
});
16 changes: 16 additions & 0 deletions lib/monitoring/addon/components/node-dashboard/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@
expandAll=al.expandAll
expandFn=expandFn
}}
{{#if isK3sNode}}
<div class="mt-20">
{{#accordion-list-item
title=(t "clusterDashboard.k3sInfo.title")
detail=(t "clusterDashboard.k3sInfo.detail")
expandAll=expandAll
expand=(action expandFn)
as | parent |
}}
<div class="row">
<K3sNodeArgs @node={{model.node}} />
<K3sNodeEnvVar @node={{model.node}} />
</div>
{{/accordion-list-item}}
</div>
{{/if}}
<div class="mt-20">
{{system-info-section
node=model.node
Expand Down
13 changes: 11 additions & 2 deletions lib/shared/addon/components/annotations-section/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { alias } from '@ember/object/computed';
import Component from '@ember/component';
import ManageLabels from 'shared/mixins/manage-labels';
import layout from './template';
import C from 'ui/utils/constants';

const K3S_LABELS_TO_IGNORE = [
C.LABEL.K3S_NODE_ARGS,
C.LABEL.K3S_NODE_CONFIG_HASH,
C.LABEL.K3S_NODE_ENV
];

export default Component.extend(ManageLabels, {
layout,
Expand All @@ -25,11 +32,13 @@ export default Component.extend(ManageLabels, {
],

annotationSource: alias('model.annotations'),

didReceiveAttrs() {
this.initLabels(this.get('annotationSource'));
this.initLabels(this.get('annotationSource'), null, null, null, K3S_LABELS_TO_IGNORE);
},

annotationsObserver: observer('model.annotations', function() {
this.initLabels(this.get('annotationSource'));
this.initLabels(this.get('annotationSource'), null, null, null, K3S_LABELS_TO_IGNORE);
}),

});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@ember/component'
import ClusterDriver from 'shared/mixins/cluster-driver';
import { inject as service } from '@ember/service';
import { get, set, observer } from '@ember/object';
import { computed, get, set, observer } from '@ember/object';
import { alias, equal } from '@ember/object/computed';
import layout from './template';

Expand All @@ -12,20 +12,35 @@ export default Component.extend(ClusterDriver, {
settings: service(),

layout,
configField: 'importedConfig',
step: 1,
loading: false,
clusterAdmin: CLUSTER_ADMIN,
configField: 'importedConfig',
step: 1,
loading: false,
nodeForInfo: null,
clusterAdmin: CLUSTER_ADMIN,

isEdit: equal('mode', 'edit'),
clusterState: alias('model.originalCluster.state'),
isK3sCluster: equal('model.cluster.driver', 'k3s'),

didReceiveAttrs() {
if ( get(this, 'isEdit') &&
get(this, 'clusterState') === 'pending'
) {
this.loadToken();
}

if ( get(this, 'isEdit') && this.isK3sCluster && this.model.cluster.masterNodes.length === 1 ) {
set(this, 'nodeForInfo', this.model.cluster.masterNodes.firstObject);
}
},

actions: {
driverUpdateK3sCluster() {
},

setActiveNodeForInfo(nodeId) {
set(this, 'nodeForInfo', this.nodes.findBy('id', nodeId));
},
},

clusterChanged: observer('originalCluster.state', function() {
Expand All @@ -40,6 +55,17 @@ export default Component.extend(ClusterDriver, {
}
}),

nodes: computed('model.cluster.masterNodes.@each.{state}', function() {
return this.model.cluster.masterNodes;
}),

nodesOptions: computed('nodes.@each.{state}', function() {
return this.nodes.map((node) => ( {
id: node.id,
displayName: node.displayName
} ));
}),

doneSaving() {
if ( get(this, 'isEdit') ) {
if (this.close) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@
{{#if (and (eq step 2) (eq originalCluster.state "pending"))}}
{{#if (and (eq step 1) isK3sCluster)}}
<AccordionList @showExpandAll={{false}} as |al expandFn|>
<AccordionListItem
@title={{t "k3sClusterInfo.title"}}
@detail={{t "k3sClusterInfo.detail"}}
@expandAll={{al.expandAll}}
@everExpanded={{true}}
@expandOnInit={{true}}
@expanded={{true}}
@expand={{action expandFn}}
>
<K3sClusterInfo
@cluster={{model.cluster}}
@originalCluster={{model.originalCluster}}
@editing={{isEdit}}
/>
</AccordionListItem>

<AccordionListItem
@title={{t "k3sClusterInfo.nodeInfo.title"}}
@detail={{t "k3sClusterInfo.nodeInfo.detail"}}
@expandAll={{al.expandAll}}
@everExpanded={{true}}
@expandOnInit={{true}}
@expanded={{true}}
@expand={{action expandFn}}
>
<div class="row">
<div class="col span-6">
<label class="acc-label" for="master-node-select">
{{t "k3sClusterInfo.nodeInfo.label"}}
</label>
{{new-select
id="master-node-select"
classNames="form-control"
optionValuePath="id"
optionLabelPath="displayName"
content=nodesOptions
value=nodeForInfo.id
action=(action "setActiveNodeForInfo")
prompt="k3sClusterInfo.nodeInfo.selectPrompt"
localizedPrompt=true
}}
</div>
{{#if nodeForInfo}}
<div class="col span-12">
<K3sNodeArgs @node={{nodeForInfo}} />
<K3sNodeEnvVar @node={{nodeForInfo}} />
</div>
{{/if}}
</div>
</AccordionListItem>
</AccordionList>

<TopErrors @errors={{errors}} />
<TopErrors @errors={{otherErrors}} />
<TopErrors @errors={{clusterErrors}} />
<SaveCancel
@save={{action "driverSave"}}
@editing={{isEdit}}
@cancel={{action "close"}}
/>
{{else if (and (eq step 2) (eq originalCluster.state "pending"))}}
{{#banner-message color="bg-info m-0"}}
<div class="mt-20">
{{t "clusterNew.import.command.instructionsAdminRole"
Expand Down
7 changes: 7 additions & 0 deletions lib/shared/addon/components/cru-cluster/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default Component.extend(ViewNewEdit, ChildHook, {
primaryResource: alias('model.cluster'),

isCustom: equal('driverInfo.nodeWhich', 'custom'),
isK3sCluster: equal('model.cluster.driver', 'k3s'),

init() {
this._super(...arguments);
Expand Down Expand Up @@ -252,6 +253,12 @@ export default Component.extend(ViewNewEdit, ChildHook, {
preSave: true
});

out.push({
name: 'k3s',
driver: 'import',
preSave: true
});

out.forEach((driver) => {
const key = `clusterNew.${ driver.name }.label`;

Expand Down
3 changes: 2 additions & 1 deletion lib/shared/addon/components/cru-cluster/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

<FormMembers
@creator={{model.me}}
@editing={{notView}}
@editing={{and notView (not isK3sCluster)}}
@expanded={{expanded}}
@isNew={{newCluster}}
@memberConfig={{memberConfig}}
Expand All @@ -85,6 +85,7 @@
expandFn=expandFn
initialLabels=model.cluster.labels
model=model.cluster
editing=(and notView (not isK3sCluster))
}}
{{/accordion-list}}
{{/if}}
Expand Down
10 changes: 10 additions & 0 deletions lib/shared/addon/components/k3s-cluster-info/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Component from '@ember/component';
import layout from './template';
import { alias } from '@ember/object/computed';

export default Component.extend({
layout,

editing: false,
k3sConfig: alias('cluster.k3sConfig'),
});
57 changes: 57 additions & 0 deletions lib/shared/addon/components/k3s-cluster-info/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<div class="row">
<div class="col span-6">
<!-- TODO use form-versions here when we have the api ready -->
<label class="acc-label">Kubernetes Version</label>
<div class="form-control">
{{#input-or-display
editable=editing
value=k3sConfig.kubernetesVersion.gitVersion
}}
{{input
id="node-kube-version"
class="form-control"
type="text"
value=k3sConfig.kubernetesVersion.gitVersion
}}
{{/input-or-display}}
</div>
</div>
</div>
<div class="row">
<div class="col span-6">
<label class="acc-label" for="node-server-concurrency">
{{t "k3sClusterInfo.serverConcurrency"}}
</label>
<div class="form-control">
{{#input-or-display
editable=editing
value=k3sConfig.serverConcurrency
}}
{{input
id="node-server-concurrency"
class="form-control"
type="number"
value=k3sConfig.serverConcurrency
}}
{{/input-or-display}}
</div>
</div>
<div class="col span-6">
<label class="acc-label" for="node-worker-concurrency">
{{t "k3sClusterInfo.workerConcurrency"}}
</label>
<div class="form-control">
{{#input-or-display
editable=editing
value=k3sConfig.workerConcurrency
}}
{{input
id="node-worker-concurrency"
class="form-control"
type="number"
value=k3sConfig.workerConcurrency
}}
{{/input-or-display}}
</div>
</div>
</div>
10 changes: 10 additions & 0 deletions lib/shared/addon/components/k3s-node-args/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Component from '@ember/component';
import layout from './template';

export default Component.extend({
layout,

classNames: ['col', 'span-12', 'box'],

node: null,
});
13 changes: 13 additions & 0 deletions lib/shared/addon/components/k3s-node-args/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<label class="acc-label">
{{t "clusterDashboard.k3sInfo.nodeArgs.title"}}
</label>
<p class="help-block">
{{t "clusterDashboard.k3sInfo.nodeArgs.detail"}}
</p>
{{#if (gte node.k3sNodeArgs.length 1)}}
<pre style="font-size: 14px;">{{node.k3sNodeArgs}}</pre>
{{else}}
<div class="mt-20 text-center">
{{t "clusterDashboard.k3sInfo.nodeArgs.noArgs"}}
</div>
{{/if}}
Loading