This change adds a new step to Kubernetes cluster lifecycle to install metrics server. The installation is done by applying a slightly modified version the official yaml file [1] of the metrics server after the cluster is provisioned. The metrics-server then installed on one of the control plane nodes. This works basically by incrementing a semaphore at the beginning of the provisioning workflow and a label hop at the wait state of KubernetesClusterNexus. This approach can be extended to user-selectable addons and tools in the future. [1] https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
31 lines
998 B
Ruby
Executable File
31 lines
998 B
Ruby
Executable File
#!/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require_relative "../../common/lib/util"
|
|
|
|
# Install metrics-server
|
|
puts "Installing metrics-server"
|
|
|
|
r "kubectl --kubeconfig /etc/kubernetes/admin.conf -n kube-system apply -f /home/ubi/kubernetes/lib/metrics-server.yaml"
|
|
|
|
sleep 5
|
|
|
|
metrics_server_up = false
|
|
5.times do
|
|
puts "Waiting for metrics server to become available"
|
|
r "kubectl --kubeconfig /etc/kubernetes/admin.conf get csr | grep Pending | grep kubelet-serving | awk '{print $1}' | xargs -r kubectl --kubeconfig /etc/kubernetes/admin.conf certificate approve"
|
|
r "kubectl --kubeconfig /etc/kubernetes/admin.conf wait deployment/metrics-server -n kube-system --for=condition=Available --timeout=10s"
|
|
metrics_server_up = true
|
|
break
|
|
rescue CommandFail
|
|
puts "Metrics server didn't become available, retrying in 5 seconds..."
|
|
sleep 5
|
|
end
|
|
|
|
unless metrics_server_up
|
|
puts "Metrics server is not healthy, need manual intervention."
|
|
exit 1
|
|
end
|
|
|
|
puts "Metrics server is up and running"
|