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

WIP MGMT-9754 Static IPs #547

Closed
Closed
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
50 changes: 50 additions & 0 deletions ui/backend/src/common/resources/NodeNetworkConfigurationPolicy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Metadata } from './metadata';
import { NNRouteConfig } from './NodeNetworkState';
import { IResource } from './resource';

export type NodeNetworkConfigurationPolicyType = 'nmstate.io/v1';
export const NodeNetworkConfigurationPolicyApiVersion: NodeNetworkConfigurationPolicyType =
'nmstate.io/v1';

export type NodeNetworkConfigurationPolicyKindType = 'NodeNetworkConfigurationPolicy';
export const NodeNetworkConfigurationPolicyKind: NodeNetworkConfigurationPolicyKindType =
'NodeNetworkConfigurationPolicy';

export type NNCPInterface = {
name: string;
state: 'up' | 'down';
type?: 'ethernet';
ipv4: {
address: {
ip: string;
'prefix-length': number;
}[];
enabled: boolean;
};
};
export interface NodeNetworkConfigurationPolicy extends IResource {
apiVersion: NodeNetworkConfigurationPolicyType;
kind: NodeNetworkConfigurationPolicyKindType;
metadata: Metadata;

spec: {
nodeSelector?: {
// kubernetes.io/hostname: ztpfw-edgecluster0-cluster-master-0
[key: string]: string;
};
desiredState: {
interfaces: NNCPInterface[];

'dns-resolver'?: {
// TODO: don't forget to set ipv4[auto-dns] to false
config: {
server: string[];
};
};

routes?: {
config?: NNRouteConfig[];
};
};
};
}
55 changes: 55 additions & 0 deletions ui/backend/src/common/resources/NodeNetworkState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Metadata } from './metadata';
import { IResource } from './resource';

export type NodeNetworkStateType = 'nmstate.io/v1beta1';
export const NodeNetworkStateApiVersion: NodeNetworkStateType = 'nmstate.io/v1beta1';

export type NodeNetworkStateKindType = 'NodeNetworkState';
export const NodeNetworkStateKind: NodeNetworkStateKindType = 'NodeNetworkState';

interface NodeNetworkStateInterface {
ipv4: {
address: {
ip: string;
'prefix-length': number;
}[];
enabled: false;
};
// ipv6: {}
type: 'ethernet' | 'anything-else-is-not-important-now';
name: string;
state: 'down' | 'up';
mtu: number;
'mac-address': string;
dhcp: boolean;
enabled: boolean;
'auto-dns': boolean;
'auto-gateway': boolean;
}

export interface NNRouteConfig {
destination: string; // subnet mask
metric: number;
'next-hop-address': string; // gateway
'next-hop-interface': string; // interface name
}

export interface NodeNetworkState extends IResource {
apiVersion: NodeNetworkStateType;
kind: NodeNetworkStateKindType;
metadata: Metadata;

status?: {
currentState?: {
'dns-resolver'?: {
running?: {
server?: string[];
};
};
interfaces?: NodeNetworkStateInterface[];
routes?: {
running?: NNRouteConfig[];
};
};
};
}
3 changes: 3 additions & 0 deletions ui/backend/src/common/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ export * from './oauthclient';
export * from './deployment';
export * from './pod';
export * from './clusteroperator';
export * from './NodeNetworkState';
export * from './NodeNetworkConfigurationPolicy';
export * from './node';
7 changes: 7 additions & 0 deletions ui/backend/src/common/resources/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export interface OwnerReference {
apiVersion: string;
kind: string;
name: string;
uid: string;
}
export interface Metadata {
name?: string;
namespace?: string;
Expand All @@ -10,4 +16,5 @@ export interface Metadata {
deletionTimestamp?: string;
selfLink?: string;
finalizers?: string[];
ownerReferences?: OwnerReference[];
}
25 changes: 25 additions & 0 deletions ui/backend/src/common/resources/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Metadata } from './metadata';
import { IResource } from './resource';

export type NodeType = 'v1';
export const NodeApiVersion: NodeType = 'v1';

export type NodeKindType = 'Node';
export const NodeKind: NodeKindType = 'Node';

export interface Node extends IResource {
apiVersion: NodeType;
kind: NodeKindType;
metadata: Metadata;
/*
node-role.kubernetes.io/master: ""
node-role.kubernetes.io/worker: ""
*/

status?: {
addresses?: {
address: string;
type: 'Hostname' | 'InternalIP';
}[];
};
}
42 changes: 42 additions & 0 deletions ui/backend/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,45 @@ export type ChangeDomainInputType = {
[key: /* ~ domain */ string]: TlsCertificate;
};
};

export type HostInterfaceType = {
name: string; // i.e. "eth0"
// type: 'ethernet' | 'bond' | 'linux-bridge';
// state: 'up' | 'down';
ipv4: {
// dhcp: boolean; always "false" for our static ips case
// enabled: boolean; always true otherwise not found
address?: {
// We support only one static IP per interface
ip?: string; // regular (dotted) IP form
prefixLength?: number;
validation?: string;

gateway?: string;
gatewayValidation?: string; // undefined if valid
};
};
};

export type HostType = {
nodeName: string; // metadata.name of the Node resource
hostname?: string; // kubernetes.io/hostname label in Node or nmstate spec.nodeSelector (optional)
nncpName?: string; // metadata.name of the NodeNetworkConfigurationPolicy (if exists)

role?: 'control' | 'worker'; // node-role.kubernetes.io/worker , node-role.kubernetes.io/master

interfaces: HostInterfaceType[];
dns?: string[];

dnsValidation?: string; // undefined if valid
};
/*
export type Network4Type = {
prefixLength: number;
dns?: string;
gw?: string;
};
*/
export type ChangeStaticIpsInputType = {
hosts?: HostType[];
};
Loading