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
1 change: 1 addition & 0 deletions GEMINI.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Before generating code:
7. Explain trade-offs when multiple implementations are reasonable.
8. Always check-out to another branch for features implementing or bugs fixing, never work on main/master.
9. Keep code small and well-organized by business logic boundaries.
10. Design for extensibility from the start: if a pattern or logic could be extended (such as rule evaluations, parsers, or handler registries), make it extensible upfront (e.g. table-driven or strategy patterns) instead of keeping it overly simplistic (e.g. long if-else chains).

Never invent APIs that do not exist.

Expand Down
39 changes: 2 additions & 37 deletions src/components/layout/AppFooter.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { useCluster } from '@/composables/useCluster'
import { useKubernetesStore } from '@/stores/kubernetesStore'
import { detectCloudProvider } from '@/utils/cloudProvider'
import { Clock, Cloud, RefreshCwIcon } from '@lucide/vue'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { KubernetesIcon } from 'vue3-simple-icons'
Expand Down Expand Up @@ -45,43 +46,7 @@ const clusterUptime = computed(() => {
})

const cloudProvider = computed(() => {
const node = kubernetesStore.nodes[0]
if (!node || !node.labels) {
return { provider: 'Local', platform: 'Custom' }
}
const labels = node.labels
let provider = 'Local'
let platform = 'Custom'

for (const label of labels) {
const l = label.toLowerCase()
if (l.includes('eks.amazonaws.com') || l.includes('aws')) {
provider = 'AWS'
platform = 'EKS'
break
} else if (l.includes('google.com') || l.includes('gke')) {
provider = 'GCP'
platform = 'GKE'
break
} else if (l.includes('azure') || l.includes('aks')) {
provider = 'Azure'
platform = 'AKS'
break
} else if (l.includes('minikube')) {
provider = 'Minikube'
platform = 'Local'
break
} else if (l.includes('k3s')) {
provider = 'K3s'
platform = 'Local'
break
} else if (l.includes('microk8s')) {
provider = 'MicroK8s'
platform = 'Local'
break
}
}
return { provider, platform }
return detectCloudProvider(kubernetesStore.nodes[0]?.labels)
})
</script>

Expand Down
59 changes: 59 additions & 0 deletions src/utils/cloudProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export interface CloudProviderInfo {
provider: string
platform: string
}

interface ProviderRule {
patterns: string[]
provider: string
platform: string
}

const PROVIDER_RULES: readonly ProviderRule[] = [
{ patterns: ['eks.amazonaws.com', 'aws'], provider: 'AWS', platform: 'EKS' },
{ patterns: ['google.com', 'gke'], provider: 'GCP', platform: 'GKE' },
{ patterns: ['azure', 'aks'], provider: 'Azure', platform: 'AKS' },
{ patterns: ['doks.digitalocean.com'], provider: 'DigitalOcean', platform: 'DOKS' },
{ patterns: ['k8s.scaleway.com'], provider: 'Scaleway', platform: 'Kapsule' },
{ patterns: ['lke.linode.com', 'linode'], provider: 'Linode', platform: 'LKE' },
{ patterns: ['vke.vultr.com', 'vultr'], provider: 'Vultr', platform: 'VKE' },
{ patterns: ['civo.com', 'civo'], provider: 'Civo', platform: 'Civo' },
{ patterns: ['oke.oraclecloud.com', 'oraclecloud'], provider: 'Oracle', platform: 'OKE' },
{ patterns: ['minikube'], provider: 'Minikube', platform: 'Local' },
{ patterns: ['k3d'], provider: 'K3d', platform: 'Local' },
{ patterns: ['k3s'], provider: 'K3s', platform: 'Local' },
{ patterns: ['k0s'], provider: 'k0s', platform: 'Local' },
{ patterns: ['microk8s'], provider: 'MicroK8s', platform: 'Local' },
{ patterns: ['docker-desktop'], provider: 'Docker', platform: 'Docker Desktop' },
{ patterns: ['kind.x-k8s.io', 'kind'], provider: 'Kind', platform: 'Local' },
{ patterns: ['talos.dev'], provider: 'Talos', platform: 'Custom' },
{ patterns: ['rancher-desktop'], provider: 'Rancher', platform: 'Rancher Desktop' },
{ patterns: ['colima'], provider: 'Colima', platform: 'Local' },
{ patterns: ['openshift'], provider: 'Red Hat', platform: 'OpenShift' }
]

export const DEFAULT_CLOUD_PROVIDER: CloudProviderInfo = {
provider: 'Local',
platform: 'Custom'
}

/**
* Detects cloud provider and platform based on Kubernetes node labels.
*/
export function detectCloudProvider(labels: string[] | undefined | null): CloudProviderInfo {
if (!labels || labels.length === 0) {
return DEFAULT_CLOUD_PROVIDER
}

for (const label of labels) {
const l = label.toLowerCase()
const match = PROVIDER_RULES.find((rule) =>
rule.patterns.some((pattern) => l.includes(pattern))
)
if (match) {
return { provider: match.provider, platform: match.platform }
}
}

return DEFAULT_CLOUD_PROVIDER
}