Skip to content
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 modify template structure #48

Merged
merged 1 commit into from
Aug 4, 2022
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
54 changes: 6 additions & 48 deletions src/pages/cluster/containers/Cluster/actions/Create/Cluster.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import {
isNumber,
} from 'utils/validate';
import {
clusterParams,
IPVersionOptions,
proxyModeOptions,
containerRuntimeOption,
networkPluginOption,
calicoModeOption,
Expand Down Expand Up @@ -79,35 +82,12 @@ export default class Cluster extends BaseForm {
);

return {
...clusterParams,
offline: !!this.state.offline,
localRegistry: '',
// kubernetesVersion: firstK8s.value,
kubernetesVersionOnline: firstK8sOnline.value,
kubernetesVersionOffline: firstK8sOffline.value,
etcdDataDir: '/var/lib/etcd',
// containerRuntime
containerRuntimeType: 'containerd',
dockerVersion: '19.03.12',
dockerRootDir: '/var/lib/docker',
// containerdVersion: firstContainerd.value,
containerdVersionOffline: firstContainerdOffline.value,
containerdVersionOnline: firstContainerdOnline.value,
containerdRootDir: '/var/lib/containerd',
// 网络
dnsDomain: 'cluster.local',
workerNodeVip: '169.254.169.100',
cniType: 'calico',
calicoMode: 'Overlay-Vxlan-All',
IPVersion: 'IPv4',
proxyMode: 'ipvs',
IPManger: true,
podIPv4CIDR: '172.25.0.0/24',
podIPv6CIDR: 'fd05::/120',
pod_network_underlay: 'first-found',
pod_network_underlay_v6: 'first-found',
mtu: 1440,
serviceSubnet: '10.96.0.0/16',
serviceSubnetV6: 'fd03::/112',
...this.props.context,
};
}
Expand Down Expand Up @@ -638,20 +618,7 @@ export default class Cluster extends BaseForm {
label: t('proxyMode'),
type: 'radio',
optionType: 'default',
options: [
{
label: 'ipvs',
value: 'ipvs',
},
{
label: 'iptables',
value: 'iptables',
},
{
label: 'ebpf',
value: 'ebpf',
},
],
options: proxyModeOptions,
},
{
name: 'IPManger',
Expand All @@ -667,16 +634,7 @@ export default class Cluster extends BaseForm {
label: t('IP Version'),
type: 'radio',
optionType: 'default',
options: [
{
label: 'IPv4',
value: 'IPv4',
},
{
label: t('IPv4 IPv6 Dual Stack'),
value: 'IPv4+IPv6',
},
],
options: IPVersionOptions,
},
{
name: 'pod_network_underlay',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class ConfirmStep extends BaseForm {
serviceSubnetV6,
},
} = this.props;
const isDualStack = IPVersion === 'dualStack';
const isDualStack = IPVersion === 'IPv4+IPv6';
if (isDualStack) {
return [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import {
isNumber,
} from 'utils/validate';
import {
clusterParams,
IPVersionOptions,
proxyModeOptions,
containerRuntimeOption,
networkPluginOption,
calicoModeOption,
Expand All @@ -48,34 +51,6 @@ const {
templatesStore,
} = rootStore;

const BASEPARAMS = {
offline: true,
localRegistry: '',
// kubernetesVersion: firstK8s?.value,
etcdDataDir: '/var/lib/etcd',
// containerRuntime
containerRuntimeType: 'containerd',
dockerVersion: '19.03.12',
dockerRootDir: '/var/lib/docker',
// containerdVersion: firstContainerd?.value,
containerdRootDir: '/var/lib/containerd',
// 网络
dnsDomain: 'cluster.local',
workerNodeVip: '169.254.169.100',
cniType: 'calico',
calicoMode: 'Overlay-Vxlan-All',
ipvs: true,
IPVersion: 'ipv4',
IPManger: true,
podIPv4CIDR: '172.25.0.0/24',
podIPv6CIDR: 'fd05::/120',
pod_network_underlay: 'first-found',
pod_network_underlay_v6: 'first-found',
mtu: 1440,
serviceSubnet: '10.96.0.0/16',
serviceSubnetV6: 'fd03::/112',
};

@observer
export default class Cluster extends BaseForm {
init() {
Expand Down Expand Up @@ -137,7 +112,7 @@ export default class Cluster extends BaseForm {
);

return {
...BASEPARAMS,
...clusterParams,
kubernetesVersionOnline: firstK8sOnline?.value,
kubernetesVersionOffline: firstK8sOffline?.value,
containerdVersionOffline: firstContainerdOffline?.value,
Expand Down Expand Up @@ -236,7 +211,7 @@ export default class Cluster extends BaseForm {
get isDualStack() {
const { IPVersion } = this.state;

return IPVersion === 'dualStack';
return IPVersion === 'IPv4+IPv6';
}

checkIpOrDomain = (rule, value) => {
Expand Down Expand Up @@ -660,13 +635,11 @@ export default class Cluster extends BaseForm {
hidden: !this.isCalico,
},
{
name: 'ipvs',
label: t('Ipvs'),
type: 'check',
content: t('Enable Ipvs'),
tip: t(
'IPVS (IP Virtual Server) is built on the upper layer of Netfilter and as a part of the Linux kernel to achieve load balancing at the transport layer. It is recommended to enable it.'
),
name: 'proxyMode',
label: t('proxyMode'),
type: 'radio',
optionType: 'default',
options: proxyModeOptions,
},
{
name: 'IPManger',
Expand All @@ -682,16 +655,7 @@ export default class Cluster extends BaseForm {
label: t('IP Version'),
type: 'radio',
optionType: 'default',
options: [
{
label: 'IPv4',
value: 'ipv4',
},
{
label: t('IPv4 IPv6 Dual Stack'),
value: 'dualStack',
},
],
options: IPVersionOptions,
},
{
name: 'pod_network_underlay',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class ConfirmStep extends BaseForm {
serviceSubnetV6,
},
} = this.props;
const isDualStack = IPVersion === 'dualStack';
const isDualStack = IPVersion === 'IPv4+IPv6';
if (isDualStack) {
return [
{
Expand Down Expand Up @@ -215,7 +215,7 @@ export class ConfirmStep extends BaseForm {
dnsDomain,
cniType,
calicoMode,
ipvs,
proxyMode,
IPManger,
IPVersion,
mtu,
Expand Down Expand Up @@ -253,8 +253,8 @@ export class ConfirmStep extends BaseForm {
value: calicoMode,
},
{
label: t('Ipvs'),
value: ipvs,
label: t('proxyMode'),
value: proxyMode,
},
{
label: t('IPManger'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default class Create extends StepAction {
IPVersion,
calicoMode,
cniType,
ipvs,
proxyMode,
podIPv4CIDR,
podIPv6CIDR,
serviceSubnet,
Expand All @@ -218,9 +218,9 @@ export default class Create extends StepAction {
// labels,
} = values;

const dualStack = IPVersion === 'dualStack';
// podSubnet 等于 podIPv4CIDR 和 podIPv6CIDR 逗号分隔合并
const podSubnet = dualStack ? `${podIPv4CIDR},${podIPv6CIDR}` : podIPv4CIDR;
const isIPv4 = IPVersion === 'IPv4';
const servicesCidr = isIPv4 ? [podIPv4CIDR] : [podIPv4CIDR, podIPv6CIDR];
const podCidr = isIPv4 ? [serviceSubnet] : [serviceSubnet, serviceSubnetV6];
const { IPv4AutoDetection, IPv6AutoDetection } =
computeAutoDetection(values);

Expand All @@ -233,54 +233,48 @@ export default class Create extends StepAction {
? kubernetesVersionOffline
: kubernetesVersionOnline,
containerRuntime: {
containerRuntimeType,
type: containerRuntimeType,
...(containerRuntimeType === 'docker'
? {
docker: {
version: dockerVersion,
insecureRegistry: this.getRegistry(dockerInsecureRegistry), // dockerInsecureRegistry,
rootDir: dockerRootDir,
},
version: dockerVersion,
insecureRegistry: this.getRegistry(dockerInsecureRegistry), // dockerInsecureRegistry,
rootDir: dockerRootDir,
}
: {
containerd: {
version: offline
? containerdVersionOffline
: containerdVersionOnline,
insecureRegistry: this.getRegistry(containerdInsecureRegistry),
rootDir: containerdRootDir,
},
version: offline
? containerdVersionOffline
: containerdVersionOnline,
insecureRegistry: this.getRegistry(containerdInsecureRegistry),
rootDir: containerdRootDir,
}),
},
networking: {
serviceSubnet: dualStack
? `${serviceSubnet},${serviceSubnetV6}`
: serviceSubnet,
dnsDomain,
podSubnet,
},
kubeComponents: {
kubeProxy: {
ipvs,
ipFamily: IPVersion,
services: {
cidrBlocks: servicesCidr,
},
etcd: {
dataDir: etcdDataDir,
dnsDomain,
pods: {
cidrBlocks: podCidr,
},
cni: {
type: cniType,
podIPv4CIDR,
podIPv6CIDR,
workerNodeVip,
proxyMode,
},
kubeProxy: {},
etcd: {
dataDir: etcdDataDir,
},
cni: {
type: cniType,
calico: {
IPv4AutoDetection,
IPv6AutoDetection,
mode: calicoMode,
IPManger,
mtu,
calico: {
IPv4AutoDetection,
IPv6AutoDetection,
mode: calicoMode,
dualStack,
IPManger,
},
},
},
components: this.getComponents(values),
addons: this.getComponents(values),
};

// eslint-disable-next-line no-console
Expand Down
Loading