Skip to content

Commit

Permalink
Add K8ssandraCluster object support and enrich cassdc details
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Jun 1, 2022
1 parent 3356403 commit 930fa70
Show file tree
Hide file tree
Showing 7 changed files with 586 additions and 4 deletions.
36 changes: 33 additions & 3 deletions k8ssandra/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ import React from "react";
import { CassandraDatacenterDetails, CassandraDatacenterDetailsProps } from "./src/components/cassdc-details";
import { CassandraDatacenterPage } from "./src/components/cassdc-page";
import { CassandraDatacenter } from "./src/cassdc"
import { K8ssandraClusterDetails, K8ssandraClusterDetailsProps } from "./src/components/k8c-details";
import { K8ssandraClusterPage } from "./src/components/k8c-page";
import { K8ssandraCluster } from "./src/k8c"

export function K8ssandraClusterIcon(props: Renderer.Component.IconProps) {
return <Renderer.Component.Icon {...props} material="lan" tooltip="K8ssandra Clusters"/>
}
export function CassandraDatacenterIcon(props: Renderer.Component.IconProps) {
return <Renderer.Component.Icon {...props} material="security" tooltip="Cassandra Datacenters"/>
return <Renderer.Component.Icon {...props} material="hive" tooltip="Cassandra Datacenters"/>
}
export function K8ssandraIcon(props: Renderer.Component.IconProps) {
return <Renderer.Component.Icon {...props} material="wb_cloudy" tooltip="K8ssandra"/>
}

export default class CassandraDatacenterExtension extends Renderer.LensExtension {
Expand All @@ -14,20 +23,34 @@ export default class CassandraDatacenterExtension extends Renderer.LensExtension
components: {
Page: () => <CassandraDatacenterPage extension={this} />,
}
},
{
id: "k8ssandraclusters",
components: {
Page: () => <K8ssandraClusterPage extension={this} />,
}
}]

clusterPageMenus = [
{
id: "k8ssandra",
title: "K8ssandra",
components: {
Icon: CassandraDatacenterIcon,
Icon: K8ssandraIcon,
}
},
{
parentId: "k8ssandra",
target: { pageId: "k8ssandraclusters" },
title: "Clusters",
components: {
Icon: K8ssandraClusterIcon,
}
},
{
parentId: "k8ssandra",
target: { pageId: "cassandradatacenters" },
title: "Cassandra Datacenters",
title: "Datacenters",
components: {
Icon: CassandraDatacenterIcon,
}
Expand All @@ -40,5 +63,12 @@ export default class CassandraDatacenterExtension extends Renderer.LensExtension
components: {
Details: (props: CassandraDatacenterDetailsProps) => <CassandraDatacenterDetails {...props} />
}
},
{
kind: K8ssandraCluster.kind,
apiVersions: ["k8ssandra.io/v1alpha1"],
components: {
Details: (props: K8ssandraClusterDetailsProps) => <K8ssandraClusterDetails {...props} />
}
}]
}
15 changes: 15 additions & 0 deletions k8ssandra/src/cassdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ export class CassandraDatacenter extends Renderer.K8sApi.KubeObject {
serverVersion: string;
serverType: string;
serverImage: string;
config: {
"cassandra-yaml": {
[key: string]: any;
},
"jvm-options": {
[key: string]: string;
},
"jvm-server-options": CassandraDatacenter["spec"]["config"]["jvm-options"],
"jvm11-server-options": {
"additional-jvm-opts": string[];
},
"cassandra-env-sh": {
"additional-jvm-opts": string[];
},
};
}
status: {
conditions: {
Expand Down
116 changes: 115 additions & 1 deletion k8ssandra/src/components/cassdc-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { CassandraDatacenter } from "../cassdc";
const {
Component: {
Badge,
DrawerItem
DrawerItem,
Table,
TableHead,
TableCell,
TableRow,
},
} = Renderer;
export interface CassandraDatacenterDetailsProps extends Renderer.Component.KubeObjectDetailsProps<CassandraDatacenter>{
Expand All @@ -25,6 +29,95 @@ export class CassandraDatacenterDetails extends React.Component<CassandraDatacen
})}
</DrawerItem>
}
const cassandraYamlHeader = <div className="drawer-title-module__DrawerTitle--mJBGT drawer-title-module__title--hFfE2">Cassandra Yaml</div>;
var cassandraYaml = <div>{cassandraYamlHeader}</div>;
if (cassdc.spec.config) {
if ("cassandra-yaml" in cassdc.spec.config) {
cassandraYaml = <div>
{cassandraYamlHeader}
<div>
<Table>
<TableHead>
<TableCell>Setting</TableCell>
<TableCell>Value</TableCell>
</TableHead>
{Object.keys(cassdc.spec.config["cassandra-yaml"]).map((key, index) => {
return (<TableRow key={"cassandraYaml" + index}>
<TableCell>{key}</TableCell>
<TableCell>{JSON.stringify(cassdc.spec.config["cassandra-yaml"][key])}</TableCell>
</TableRow>);
})}
</Table>
</div>
</div>;
}
}

const jvmOptionsHeader = <div className="drawer-title-module__DrawerTitle--mJBGT drawer-title-module__title--hFfE2">JVM Options</div>;
var jvmOptions = <div>{jvmOptionsHeader}</div>;
if (cassdc.spec.config) {
if ("jvm-options" in cassdc.spec.config) {
jvmOptions = <div>
{jvmOptionsHeader}
{displayJvmOptions(cassdc.spec.config["jvm-options"])}
</div>;
}
}

const jvmServerOptionsHeader = <div className="drawer-title-module__DrawerTitle--mJBGT drawer-title-module__title--hFfE2">JVM Server Options</div>;
var jvmOptions = <div>{jvmOptionsHeader}</div>;
if (cassdc.spec.config) {
if ("jvm-server-options" in cassdc.spec.config) {
jvmOptions = <div>
{jvmServerOptionsHeader}
{displayJvmOptions(cassdc.spec.config["jvm-server-options"])}
</div>;
}
}

const jvm11OptionsHeader = <div className="drawer-title-module__DrawerTitle--mJBGT drawer-title-module__title--hFfE2">JVM11 Server Options</div>;
var jvm11Options = <div>{jvm11OptionsHeader}</div>;
if (cassdc.spec.config) {
if ("jvm11-server-options" in cassdc.spec.config && "additional-jvm-opts" in cassdc.spec.config["jvm11-server-options"]) {
jvm11Options = <div>
{jvm11OptionsHeader}
<div>
<Table>
<TableHead>
<TableCell>Setting</TableCell>
</TableHead>
{cassdc.spec.config["jvm11-server-options"]["additional-jvm-opts"].map((setting, index) => {
return (<TableRow key={"jvm11ServerOptions" + index}>
<TableCell>{setting}</TableCell>
</TableRow>);
})}
</Table>
</div>
</div>;
}
}

const cassandraEnvHeader = <div className="drawer-title-module__DrawerTitle--mJBGT drawer-title-module__title--hFfE2">cassandra-env.sh</div>;
var cassandraEnvOptions = <div>{cassandraEnvHeader}</div>;
if (cassdc.spec.config) {
if ("cassandra-env-sh" in cassdc.spec.config && "additional-jvm-opts" in cassdc.spec.config["cassandra-env-sh"]) {
cassandraEnvOptions = <div>
{cassandraEnvHeader}
<div>
<Table>
<TableHead>
<TableCell>Setting</TableCell>
</TableHead>
{cassdc.spec.config["cassandra-env-sh"]["additional-jvm-opts"].map((setting, index) => {
return (<TableRow key={"cassandra-env-sh" + index}>
<TableCell>{setting}</TableCell>
</TableRow>);
})}
</Table>
</div>
</div>;
}
}

return (
<div className="CassandraDatacenter">
Expand Down Expand Up @@ -69,7 +162,28 @@ export class CassandraDatacenterDetails extends React.Component<CassandraDatacen
})}
</DrawerItem>
{nodeReplacements}
{cassandraYaml}
{jvmOptions}
{jvm11Options}
{cassandraEnvOptions}
</div>
)
}
}

function displayJvmOptions(jvmOptions: CassandraDatacenter["spec"]["config"]["jvm-options"]) {
return <div>
<Table>
<TableHead>
<TableCell>Setting</TableCell>
<TableCell>Value</TableCell>
</TableHead>
{Object.keys(jvmOptions).map((key, index) => {
return (<TableRow key={"jvmServerOptions" + index}>
<TableCell>{key}</TableCell>
<TableCell>{jvmOptions[key]}</TableCell>
</TableRow>);
})}
</Table>
</div>;
}
Loading

0 comments on commit 930fa70

Please sign in to comment.