Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update metrics feature components #301

Merged
merged 1 commit into from
Apr 28, 2020
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
10 changes: 7 additions & 3 deletions src/features/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface MetricsConfiguration {

export class MetricsFeature extends Feature {
name = 'metrics';
latestVersion = "v2.11.1"
latestVersion = "v2.17.2-lens1"

config: MetricsConfiguration = {
persistence: {
Expand All @@ -40,7 +40,7 @@ export class MetricsFeature extends Feature {
enabled: true,
},
retention: {
time: "7d",
time: "2d",
size: "5GB",
},
kubeStateMetrics: {
Expand All @@ -65,6 +65,10 @@ export class MetricsFeature extends Feature {
return super.install(cluster)
}

async upgrade(cluster: Cluster): Promise<boolean> {
return this.install(cluster)
}

async featureStatus(kc: KubeConfig): Promise<FeatureStatus> {
return new Promise<FeatureStatus>( async (resolve, reject) => {
const client = kc.makeApiClient(AppsV1Api)
Expand All @@ -79,7 +83,7 @@ export class MetricsFeature extends Feature {
const prometheus = (await client.readNamespacedStatefulSet('prometheus', 'lens-metrics')).body;
status.installed = true;
status.currentVersion = prometheus.spec.template.spec.containers[0].image.split(":")[1];
status.canUpgrade = semver.lt(status.currentVersion, this.latestVersion)
status.canUpgrade = semver.lt(status.currentVersion, this.latestVersion, true);
resolve(status)
} catch(error) {
resolve(status)
Expand Down
2 changes: 1 addition & 1 deletion src/features/metrics/03-statefulset.yml.hb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spec:
mountPath: /var/lib/prometheus
containers:
- name: prometheus
image: docker.io/kontenapharos/prometheus:v2.11.1
image: docker.io/prom/prometheus:v2.17.2
args:
- --web.listen-address=0.0.0.0:9090
- --config.file=/etc/prometheus/prometheus.yaml
Expand Down
3 changes: 3 additions & 0 deletions src/features/metrics/05-clusterrole.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- nodes/metrics
- services
- endpoints
- pods
- ingresses
- configmaps
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
4 changes: 2 additions & 2 deletions src/features/metrics/10-node-exporter-ds.yml.hb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
hostPID: true
containers:
- name: node-exporter
image: docker.io/kontenapharos/prometheus-node-exporter:v0.18.0
image: docker.io/prom/node-exporter:v1.0.0-rc.0
args:
- --path.procfs=/host/proc
- --path.sysfs=/host/sys
Expand All @@ -54,7 +54,7 @@ spec:
resources:
requests:
cpu: 10m
memory: 50Mi
memory: 24Mi
limits:
cpu: 200m
memory: 100Mi
Expand Down
155 changes: 109 additions & 46 deletions src/features/metrics/12-kube-state-metrics-clusterrole.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,112 @@ kind: ClusterRole
metadata:
name: lens-kube-state-metrics
rules:
- apiGroups: [""]
resources:
- configmaps
- secrets
- nodes
- pods
- services
- resourcequotas
- replicationcontrollers
- limitranges
- persistentvolumeclaims
- persistentvolumes
- namespaces
- endpoints
verbs: ["list", "watch"]
- apiGroups: ["extensions"]
resources:
- daemonsets
- deployments
- replicasets
- ingresses
verbs: ["list", "watch"]
- apiGroups: ["apps"]
resources:
- daemonsets
- deployments
- replicasets
- statefulsets
verbs: ["list", "watch"]
- apiGroups: ["batch"]
resources:
- cronjobs
- jobs
verbs: ["list", "watch"]
- apiGroups: ["autoscaling"]
resources:
- horizontalpodautoscalers
verbs: ["list", "watch"]
- apiGroups: ["policy"]
resources:
- poddisruptionbudgets
verbs: ["list", "watch"]
- apiGroups: ["certificates.k8s.io"]
resources:
- certificatesigningrequests
verbs: ["list", "watch"]
- apiGroups:
- ""
resources:
- configmaps
- secrets
- nodes
- pods
- services
- resourcequotas
- replicationcontrollers
- limitranges
- persistentvolumeclaims
- persistentvolumes
- namespaces
- endpoints
verbs:
- list
- watch
- apiGroups:
- extensions
resources:
- daemonsets
- deployments
- replicasets
- ingresses
verbs:
- list
- watch
- apiGroups:
- apps
resources:
- statefulsets
- daemonsets
- deployments
- replicasets
verbs:
- list
- watch
- apiGroups:
- batch
resources:
- cronjobs
- jobs
verbs:
- list
- watch
- apiGroups:
- autoscaling
resources:
- horizontalpodautoscalers
verbs:
- list
- watch
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- list
- watch
- apiGroups:
- certificates.k8s.io
resources:
- certificatesigningrequests
verbs:
- list
- watch
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
- volumeattachments
verbs:
- list
- watch
- apiGroups:
- admissionregistration.k8s.io
resources:
- mutatingwebhookconfigurations
- validatingwebhookconfigurations
verbs:
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- networkpolicies
verbs:
- list
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- list
- watch
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
serviceAccountName: kube-state-metrics
containers:
- name: kube-state-metrics
image: docker.io/kontenapharos/prometheus-kube-state-metrics:v1.6.0
image: quay.io/coreos/kube-state-metrics:v1.9.5
ports:
- name: metrics
containerPort: 8080
Expand Down
4 changes: 4 additions & 0 deletions src/features/user-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export class UserModeFeature extends Feature {
return super.install(cluster)
}

async upgrade(cluster: Cluster): Promise<boolean> {
return true
}

async featureStatus(kc: KubeConfig): Promise<FeatureStatus> {
return new Promise<FeatureStatus>( async (resolve, reject) => {
const client = kc.makeApiClient(RbacAuthorizationV1Api)
Expand Down
11 changes: 11 additions & 0 deletions src/main/cluster-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ export class ClusterManager {
}
});

this.promiseIpc.on("upgradeFeature", async (installReq: FeatureInstallRequest) => {
logger.debug(`IPC: upgradeFeature for ${installReq.name}`)
const cluster = this.clusters.get(installReq.clusterId)
try {
await cluster.upgradeFeature(installReq.name, installReq.config)
return {success: true, message: ""}
} catch(error) {
return {success: false, message: error}
}
});

this.promiseIpc.on("uninstallFeature", async (installReq: FeatureInstallRequest) => {
logger.debug(`IPC: uninstallFeature for ${installReq.name}`)
const cluster = this.clusters.get(installReq.clusterId)
Expand Down
5 changes: 5 additions & 0 deletions src/main/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export class Cluster implements ClusterInfo {
return this.refreshCluster()
}

public async upgradeFeature(name: string, config: any) {
await fm.upgradeFeature(name, this, config)
return this.refreshCluster()
}

public async uninstallFeature(name: string) {
await fm.uninstallFeature(name, this)
return this.refreshCluster()
Expand Down
6 changes: 5 additions & 1 deletion src/main/feature-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export async function installFeature(name: string, cluster: Cluster, config: any
await feature.install(cluster)
}


export async function upgradeFeature(name: string, cluster: Cluster, config: any) {
const feature = ALL_FEATURES[name] as Feature
// TODO Figure out how to handle config stuff
await feature.upgrade(cluster)
}

export async function uninstallFeature(name: string, cluster: Cluster) {
const feature = ALL_FEATURES[name] as Feature
Expand Down
4 changes: 1 addition & 3 deletions src/main/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export abstract class Feature {
});
}

upgrade(): boolean {
return true;
}
abstract async upgrade(cluster: Cluster): Promise<boolean>;

abstract async uninstall(cluster: Cluster): Promise<boolean>;

Expand Down
Loading