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

feat: K8s client update #2082

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
76f94af
k8s client fixed
vivek-devtron Feb 14, 2024
67a0d13
Merge branch 'main' into k8s_client
vivek-devtron Feb 22, 2024
b1f7fe6
Merge branch 'main' into k8s_client
vivek-devtron Feb 28, 2024
b435701
Merge branch 'main' into k8s_client
vivek-devtron Apr 9, 2024
e4df5a7
removed unused file
vivek-devtron Apr 9, 2024
08c7475
Merge branch 'main' into k8s_client
vivek-devtron May 20, 2024
5c149f2
Main sync
vivek-devtron Sep 11, 2024
eadb4fe
Merge branch 'develop' into k8s_client
vivek-devtron Sep 11, 2024
ad7440d
Merge branch 'main' into k8s_client
vivek-devtron Sep 13, 2024
88f6bd7
k8s client command update
vivek-devtron Sep 16, 2024
2304094
Merge branch 'main' into k8s_client
vivek-devtron Sep 16, 2024
a13767b
Added check for add env and enabled cluster readme in K8SClient
vivek-devtron Sep 16, 2024
a6de2d4
added Desktop client check
vivek-devtron Sep 18, 2024
329f4e1
made k8sClient equivalent to superAdmin
vivek-devtron Sep 18, 2024
fc3704c
Added orchestrator root
vivek-devtron Sep 18, 2024
fa0c01a
Default cluster check for k8sClient
vivek-devtron Sep 20, 2024
1b1da92
merged main
vivek-devtron Sep 23, 2024
d6ae8d2
Merged develop
vivek-devtron Sep 23, 2024
ace4151
added formatting
vivek-devtron Sep 23, 2024
4f7490d
Merge branch 'develop' into k8s_client
vivek-devtron Sep 23, 2024
94a23d7
fixed no env message
vivek-devtron Sep 24, 2024
9b80bc3
fixed delete cluster for k8sClient
vivek-devtron Sep 24, 2024
5866b7f
Merge branch 'develop' into k8s_client
vivek-devtron Sep 24, 2024
a96a977
reverted the merge change
vivek-devtron Sep 24, 2024
63c7fa8
fix: Cluster name missing on terminal
vivek-devtron Sep 27, 2024
c9faafb
Revert: default BE url
vivek-devtron Sep 27, 2024
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
2 changes: 0 additions & 2 deletions .env.k8sApp

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"build": "NODE_OPTIONS=--max_old_space_size=4096 vite build",
"serve": "vite preview",
"build-light": "NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false vite build",
"build-k8s-app": "NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false VITE_K8S_CLIENT=true vite build",
"build-k8s-app": "NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false vite build --mode K8S_CLIENT",
"test": "vitest test",
"test-coverage:watch": "npm run test -- --coverage",
"test-coverage": "npm run test -- --coverage --watchAll=false",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ClusterNodes/ClusterOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function ClusterOverview({ isSuperAdmin, selectedCluster }: ClusterOverviewProps
<GenericDescription
isClusterTerminal
clusterId={clusterId}
isSuperAdmin={isSuperAdmin}
isSuperAdmin={window._env_.K8S_CLIENT || isSuperAdmin}
descriptionId={descriptionData.descriptionId}
initialDescriptionText={descriptionData.descriptionText}
initialDescriptionUpdatedBy={descriptionData.descriptionUpdatedBy}
Expand Down
26 changes: 15 additions & 11 deletions src/components/ClusterNodes/ClusterSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,22 @@ const ClusterSelectionList: React.FC<ClusterSelectionType> = ({
{/* NOTE: visible-hover plays with display prop; therefore need to set display: flex on a new div */}
<div className="cursor dc__visible-hover--child ml-8">
<div className="flexbox dc__align-items-center dc__gap-4">
{!!clusterData.nodeCount && !clusterListLoader && isSuperAdmin && (
<Tooltip alwaysShowTippyOnHover content="View terminal">
<div className="flex">
<TerminalIcon
data-testid={`cluster-terminal-${clusterData.name}`}
className="icon-dim-24 p-4 dc__no-shrink dc__hover-n100 br-4 dc__hover-color-n800 fill"
onClick={getOpenTerminalHandler(clusterData)}
/>
</div>
</Tooltip>
{!!clusterData.nodeCount &&
!clusterListLoader &&
(isSuperAdmin || window._env_.K8S_CLIENT) && (
<Tooltip alwaysShowTippyOnHover content="View terminal">
<div className="flex">
<TerminalIcon
data-testid={`cluster-terminal-${clusterData.name}`}
className="icon-dim-24 p-4 dc__no-shrink dc__hover-n100 br-4 dc__hover-color-n800 fill"
onClick={getOpenTerminalHandler(clusterData)}
/>
</div>
</Tooltip>
)}
{!window._env_.K8S_CLIENT && KubeConfigButton && (
<KubeConfigButton clusterName={clusterData.name} />
)}
{KubeConfigButton && <KubeConfigButton clusterName={clusterData.name} />}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const ResourceList = () => {
[clusterId, clusterOptions],
)

const isSuperAdmin = !!userRole?.result.superAdmin
const isSuperAdmin = (selectedCluster.label && window._env_.K8S_CLIENT) || !!userRole?.result.superAdmin

const isOverviewNodeType = nodeType === SIDEBAR_KEYS.overviewGVK.Kind.toLowerCase()
const isTerminalNodeType = nodeType === AppDetailsTabs.terminal
Expand Down
202 changes: 104 additions & 98 deletions src/components/cluster/Cluster.tsx

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions src/components/cluster/ClusterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import { ReactComponent as InfoIcon } from '../../assets/icons/info-filled.svg'
import ClusterInfoStepsModal from './ClusterInfoStepsModal'
import { UPLOAD_STATE } from '@Pages/GlobalConfigurations/DeploymentCharts/types'
import UserNameDropDownList from './UseNameListDropdown'
import { clusterId } from '../ClusterNodes/__mocks__/clusterAbout.mock'
import { getModuleInfo } from '../v2/devtronStackManager/DevtronStackManager.service'
import { RemoteConnectionType } from '../dockerRegistry/dockerType'

Expand Down Expand Up @@ -140,7 +139,7 @@ export default function ClusterForm({
const authenTicationType = prometheusAuth?.userName ? AuthenticationType.BASIC : AuthenticationType.ANONYMOUS

const isDefaultCluster = (): boolean => {
return id == 1
return id == DEFAULT_CLUSTER_ID
}
const [deleting, setDeleting] = useState(false)
const [confirmation, toggleConfirmation] = useState(false)
Expand All @@ -164,7 +163,7 @@ export default function ClusterForm({

const [, grafanaModuleStatus] = useAsync(
() => getModuleInfo(ModuleNameMap.GRAFANA),
[clusterId],
[DEFAULT_CLUSTER_ID],
!window._env_.K8S_CLIENT,
)

Expand Down Expand Up @@ -442,7 +441,7 @@ export default function ClusterForm({
}

const handleOnBlur = (e): void => {
if (id && id !== 1 && !e.target.value) {
if (id && id !== DEFAULT_CLUSTER_ID && !e.target.value) {
e.target.value = DEFAULT_SECRET_PLACEHOLDER
}
}
Expand Down Expand Up @@ -735,9 +734,7 @@ export default function ClusterForm({
name="token"
value={
id
? id !== 1
? DEFAULT_SECRET_PLACEHOLDER
: config?.bearer_token
? config?.bearer_token
? config.bearer_token
: ''
: state.token.value
Expand Down Expand Up @@ -808,7 +805,7 @@ export default function ClusterForm({
className="dc__resizable-textarea__with-max-height w-100"
name="certificateAuthorityData"
value={
id && id !== 1 && isTlsConnection
id && id !== DEFAULT_CLUSTER_ID && isTlsConnection
? DEFAULT_SECRET_PLACEHOLDER
: state.certificateAuthorityData.value
}
Expand All @@ -833,7 +830,7 @@ export default function ClusterForm({
className="dc__resizable-textarea__with-max-height w-100"
name="tlsClientKey"
value={
id && id !== 1 && isTlsConnection
id && id !== DEFAULT_CLUSTER_ID && isTlsConnection
? DEFAULT_SECRET_PLACEHOLDER
: state.tlsClientKey.value
}
Expand All @@ -858,7 +855,7 @@ export default function ClusterForm({
className="dc__resizable-textarea__with-max-height w-100"
name="tlsClientCert"
value={
id && id !== 1 && isTlsConnection
id && id !== DEFAULT_CLUSTER_ID && isTlsConnection
? DEFAULT_SECRET_PLACEHOLDER
: state.tlsClientCert.value
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/cluster/cluster.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { OptionType } from '../app/types'

export const POLLING_INTERVAL = 30000

export const DEFAULT_CLUSTER_ID = 1
export const DEFAULT_CLUSTER_ID = window._env_.K8S_CLIENT ? -1 : 1

export const AuthenticationType = {
BASIC: 'BASIC',
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ declare global {

if (!window.__BASE_URL__ || !window.__ORCHESTRATOR_ROOT__) {
window.__BASE_URL__ = import.meta.env.BASE_URL || '/dashboard'
window.__ORCHESTRATOR_ROOT__ = import.meta.env.VITE_ORCHESTRATOR_ROOT || 'orchestrator'
window.__ORCHESTRATOR_ROOT__ = import.meta.env.VITE_ORCHESTRATOR_ROOT || '/orchestrator'
window.__GRAFANA_ORG_ID__ = import.meta.env.VITE_GRAFANA_ORG_ID || 2
}

Expand Down
2 changes: 1 addition & 1 deletion vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const jsToBottomNoModule = () => {

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') }
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), ''), VITE_K8S_CLIENT: `${mode === 'K8S_CLIENT'}` }
const baseConfig = {
base: '/dashboard',
preview: {
Expand Down
Loading