Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ed59321e4 |
@@ -43,7 +43,7 @@ func pfDnsCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight DNS check
|
||||
namespace, kubeConfigContents, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight DNS check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
@@ -51,11 +51,11 @@ func pfDnsCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
namespace = "default"
|
||||
}
|
||||
if err = qp.CheckDns(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight DNS check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight DNS check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -81,16 +81,16 @@ func pfK8sVersionCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight Kubernetes minimum version check
|
||||
namespace, kubeConfigContents, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight kubernetes minimum version check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
if err = qp.CheckK8sVersion(namespace, kubeConfigContents); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight kubernetes minimum version check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight kubernetes minimum version check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func pfDeploymentCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight deployments check
|
||||
namespace, kubeConfigContents, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight deployment check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
@@ -165,11 +165,11 @@ func pfDeploymentCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
namespace = "default"
|
||||
}
|
||||
if err = qp.CheckDeployment(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight deployment check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight deployment check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -195,7 +195,7 @@ func pfServiceCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight service check
|
||||
namespace, kubeConfigContents, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight service check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
@@ -204,11 +204,11 @@ func pfServiceCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
namespace = "default"
|
||||
}
|
||||
if err = qp.CheckService(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight service check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight service check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -234,7 +234,7 @@ func pfPodCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight pod check
|
||||
namespace, kubeConfigContents, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight pod check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
@@ -242,11 +242,11 @@ func pfPodCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
namespace = "default"
|
||||
}
|
||||
if err = qp.CheckPod(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight pod check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight pod check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -272,16 +272,16 @@ func pfCreateRoleCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight role check
|
||||
namespace, _, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight role check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
if err = qp.CheckCreateRole(namespace, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight role check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight role check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -307,16 +307,16 @@ func pfCreateRoleBindingCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight createRoleBinding check
|
||||
namespace, _, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight rolebinding check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
if err = qp.CheckCreateRoleBinding(namespace, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight rolebinding check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight rolebinding check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -342,16 +342,16 @@ func pfCreateServiceAccountCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight createServiceAccount check
|
||||
namespace, _, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight ServiceAccount check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
if err = qp.CheckCreateServiceAccount(namespace, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight ServiceAccount check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight ServiceAccount check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -376,16 +376,16 @@ func pfCreateAuthCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight authcheck
|
||||
namespace, kubeConfigContents, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight authcheck FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
if err = qp.CheckCreateRB(namespace, kubeConfigContents); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight authcheck FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight authcheck PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -411,7 +411,7 @@ func pfMongoCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
// Preflight mongo check
|
||||
namespace, kubeConfigContents, err := qp.CG.LoadKubeConfigAndNamespace()
|
||||
if err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight mongo check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
@@ -419,11 +419,11 @@ func pfMongoCheckCmd(q *qliksense.Qliksense) *cobra.Command {
|
||||
namespace = "default"
|
||||
}
|
||||
if err = qp.CheckMongo(kubeConfigContents, namespace, preflightOpts, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight mongo check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", Green("Preflight mongo check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n", Green("PASSED"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -13,7 +12,6 @@ import (
|
||||
"github.com/mitchellh/go-homedir"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/rbac/v1beta1"
|
||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -26,6 +24,8 @@ import (
|
||||
|
||||
var gracePeriod int64 = 0
|
||||
|
||||
var waitTimeout = 2 * time.Minute
|
||||
|
||||
type ClientGoUtils struct {
|
||||
Verbose bool
|
||||
}
|
||||
@@ -371,7 +371,6 @@ func (p *ClientGoUtils) GetPodContainerLogs(clientset kubernetes.Interface, pod
|
||||
return "", err
|
||||
}
|
||||
defer podLogs.Close()
|
||||
time.Sleep(15 * time.Second)
|
||||
buf := new(bytes.Buffer)
|
||||
_, err = io.Copy(buf, podLogs)
|
||||
if err != nil {
|
||||
@@ -382,7 +381,7 @@ func (p *ClientGoUtils) GetPodContainerLogs(clientset kubernetes.Interface, pod
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) waitForResource(checkFunc func() (interface{}, error), validateFunc func(interface{}) bool) error {
|
||||
timeout := time.NewTicker(2 * time.Minute)
|
||||
timeout := time.NewTicker(waitTimeout)
|
||||
defer timeout.Stop()
|
||||
OUT:
|
||||
for {
|
||||
@@ -514,142 +513,6 @@ func (p *ClientGoUtils) WaitForDeploymentToDelete(clientset kubernetes.Interface
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) CreatePfRole(clientset kubernetes.Interface, namespace, roleName string) (*v1beta1.Role, error) {
|
||||
// build the role defination we want to create
|
||||
var role *v1beta1.Role
|
||||
roleSpec := &v1beta1.Role{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: roleName,
|
||||
Namespace: namespace,
|
||||
Labels: map[string]string{
|
||||
"app": "preflight",
|
||||
},
|
||||
},
|
||||
Rules: []v1beta1.PolicyRule{},
|
||||
}
|
||||
|
||||
// now create the role in kubernetes cluster using the clientset
|
||||
if err := p.RetryOnError(func() (err error) {
|
||||
role, err = clientset.RbacV1beta1().Roles(namespace).Create(roleSpec)
|
||||
return err
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.LogVerboseMessage("Created role: %s\n", role.Name)
|
||||
|
||||
return role, nil
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) DeleteRole(clientset kubernetes.Interface, namespace string, roleName string) error {
|
||||
rolesClient := clientset.RbacV1beta1().Roles(namespace)
|
||||
|
||||
deletePolicy := v1.DeletePropagationForeground
|
||||
deleteOptions := v1.DeleteOptions{
|
||||
PropagationPolicy: &deletePolicy,
|
||||
}
|
||||
err := rolesClient.Delete(roleName, &deleteOptions)
|
||||
if err != nil {
|
||||
log.Printf("Error: %v\n", err)
|
||||
return err
|
||||
}
|
||||
p.LogVerboseMessage("Deleted role: %s\n\n", roleName)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) CreatePfRoleBinding(clientset kubernetes.Interface, namespace, roleBindingName string) (*v1beta1.RoleBinding, error) {
|
||||
var roleBinding *v1beta1.RoleBinding
|
||||
// build the rolebinding defination we want to create
|
||||
roleBindingSpec := &v1beta1.RoleBinding{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: roleBindingName,
|
||||
Namespace: namespace,
|
||||
Labels: map[string]string{
|
||||
"app": "preflight",
|
||||
},
|
||||
},
|
||||
Subjects: []v1beta1.Subject{
|
||||
{
|
||||
Kind: "ServiceAccount",
|
||||
APIGroup: "",
|
||||
Name: "preflight-check-subject",
|
||||
Namespace: namespace,
|
||||
},
|
||||
},
|
||||
RoleRef: v1beta1.RoleRef{
|
||||
APIGroup: "",
|
||||
Kind: "Role",
|
||||
Name: "preflight-check-roleref",
|
||||
},
|
||||
}
|
||||
|
||||
// now create the roleBinding in kubernetes cluster using the clientset
|
||||
if err := p.RetryOnError(func() (err error) {
|
||||
roleBinding, err = clientset.RbacV1beta1().RoleBindings(namespace).Create(roleBindingSpec)
|
||||
return err
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.LogVerboseMessage("Created RoleBinding: %s\n", roleBindingSpec.Name)
|
||||
return roleBinding, nil
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) DeleteRoleBinding(clientset kubernetes.Interface, namespace string, roleBindingName string) error {
|
||||
roleBindingClient := clientset.RbacV1beta1().RoleBindings(namespace)
|
||||
|
||||
deletePolicy := v1.DeletePropagationForeground
|
||||
deleteOptions := v1.DeleteOptions{
|
||||
PropagationPolicy: &deletePolicy,
|
||||
}
|
||||
err := roleBindingClient.Delete(roleBindingName, &deleteOptions)
|
||||
if err != nil {
|
||||
log.Printf("Error: %v\n", err)
|
||||
return err
|
||||
}
|
||||
p.LogVerboseMessage("Deleted RoleBinding: %s\n\n", roleBindingName)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) CreatePfServiceAccount(clientset kubernetes.Interface, namespace, serviceAccountName string) (*apiv1.ServiceAccount, error) {
|
||||
var serviceAccount *apiv1.ServiceAccount
|
||||
// build the serviceAccount defination we want to create
|
||||
serviceAccountSpec := &apiv1.ServiceAccount{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: "preflight-check-test-serviceaccount",
|
||||
Namespace: namespace,
|
||||
Labels: map[string]string{
|
||||
"app": "preflight",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// now create the serviceAccount in kubernetes cluster using the clientset
|
||||
if err := p.RetryOnError(func() (err error) {
|
||||
serviceAccount, err = clientset.CoreV1().ServiceAccounts(namespace).Create(serviceAccountSpec)
|
||||
return err
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.LogVerboseMessage("Created Service Account: %s\n", serviceAccountSpec.Name)
|
||||
return serviceAccount, nil
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) DeleteServiceAccount(clientset kubernetes.Interface, namespace string, serviceAccountName string) error {
|
||||
serviceAccountClient := clientset.CoreV1().ServiceAccounts(namespace)
|
||||
|
||||
deletePolicy := v1.DeletePropagationForeground
|
||||
deleteOptions := v1.DeleteOptions{
|
||||
PropagationPolicy: &deletePolicy,
|
||||
}
|
||||
err := serviceAccountClient.Delete(serviceAccountName, &deleteOptions)
|
||||
if err != nil {
|
||||
log.Printf("Error: %v\n", err)
|
||||
return err
|
||||
}
|
||||
p.LogVerboseMessage("Deleted ServiceAccount: %s\n\n", serviceAccountName)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) CreatePreflightTestSecret(clientset kubernetes.Interface, namespace, secretName string, secretData []byte) (*apiv1.Secret, error) {
|
||||
var secret *apiv1.Secret
|
||||
var err error
|
||||
@@ -755,16 +618,6 @@ func (p *ClientGoUtils) CreateStatefulSet(clientset kubernetes.Interface, namesp
|
||||
return statefulset, nil
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) GetPodsForStatefulset(clientset kubernetes.Interface, statefulset *appsv1.StatefulSet, namespace string) (*apiv1.PodList, error) {
|
||||
set := labels.Set(statefulset.Spec.Template.Labels)
|
||||
listOptions := v1.ListOptions{LabelSelector: set.AsSelector().String()}
|
||||
pods, err := clientset.CoreV1().Pods(namespace).List(listOptions)
|
||||
for _, pod := range pods.Items {
|
||||
LogDebugMessage("pod: %v\n", pod.Name)
|
||||
}
|
||||
return pods, err
|
||||
}
|
||||
|
||||
func (p *ClientGoUtils) waitForStatefulSet(clientset kubernetes.Interface, namespace string, pfStatefulset *appsv1.StatefulSet) error {
|
||||
var err error
|
||||
statefulsetName := pfStatefulset.GetName()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,90 +15,90 @@ func (qp *QliksensePreflight) RunAllPreflightChecks(kubeConfigContents []byte, n
|
||||
out := ansi.NewColorableStdout()
|
||||
// Preflight minimum kuberenetes version check
|
||||
if err := qp.CheckK8sVersion(namespace, kubeConfigContents); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight kubernetes minimum version check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight kubernetes minimum version check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight deployment check
|
||||
if err := qp.CheckDeployment(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight deployment check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight deployment check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight service check
|
||||
if err := qp.CheckService(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight service check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight service check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight pod check
|
||||
if err := qp.CheckPod(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight pod check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight pod check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight role check
|
||||
if err := qp.CheckCreateRole(namespace, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red("Preflight role check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight role check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight rolebinding check
|
||||
if err := qp.CheckCreateRoleBinding(namespace, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red(" Preflight rolebinding check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight rolebinding check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight serviceaccount check
|
||||
if err := qp.CheckCreateServiceAccount(namespace, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red(" Preflight serviceaccount check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight serviceaccount check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight mongo check
|
||||
if err := qp.CheckMongo(kubeConfigContents, namespace, preflightOpts, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red(" Preflight mongo check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight mongo check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
// Preflight DNS check
|
||||
if err := qp.CheckDns(namespace, kubeConfigContents, false); err != nil {
|
||||
fmt.Fprintf(out, "%s\n", Red(" Preflight DNS check FAILED"))
|
||||
fmt.Fprintf(out, "%s\n", Red("FAILED"))
|
||||
fmt.Printf("Error: %v\n\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\n\n", Green("Preflight DNS check PASSED"))
|
||||
fmt.Fprintf(out, "%s\n\n", Green("PASSED"))
|
||||
checkCount++
|
||||
}
|
||||
totalCount++
|
||||
|
||||
@@ -15,8 +15,8 @@ func (p *QliksensePreflight) CheckDeployment(namespace string, kubeConfigContent
|
||||
|
||||
// Deployment check
|
||||
if !cleanup {
|
||||
p.CG.LogVerboseMessage("Preflight deployment check: \n")
|
||||
p.CG.LogVerboseMessage("--------------------------- \n")
|
||||
fmt.Print("Preflight deployment check... ")
|
||||
p.CG.LogVerboseMessage("\n--------------------------- \n")
|
||||
}
|
||||
err = p.checkPfDeployment(clientset, namespace, cleanup)
|
||||
if err != nil {
|
||||
@@ -38,8 +38,8 @@ func (p *QliksensePreflight) CheckService(namespace string, kubeConfigContents [
|
||||
}
|
||||
// Service check
|
||||
if !cleanup {
|
||||
p.CG.LogVerboseMessage("Preflight service check: \n")
|
||||
p.CG.LogVerboseMessage("------------------------ \n")
|
||||
fmt.Print("Preflight service check... ")
|
||||
p.CG.LogVerboseMessage("\n------------------------ \n")
|
||||
}
|
||||
err = p.checkPfService(clientset, namespace, cleanup)
|
||||
if err != nil {
|
||||
@@ -61,8 +61,8 @@ func (p *QliksensePreflight) CheckPod(namespace string, kubeConfigContents []byt
|
||||
}
|
||||
// Pod check
|
||||
if !cleanup {
|
||||
p.CG.LogVerboseMessage("Preflight pod check: \n")
|
||||
p.CG.LogVerboseMessage("-------------------- \n")
|
||||
fmt.Print("Preflight pod check... ")
|
||||
p.CG.LogVerboseMessage("\n-------------------- \n")
|
||||
}
|
||||
err = p.checkPfPod(clientset, namespace, cleanup)
|
||||
if err != nil {
|
||||
|
||||
@@ -18,8 +18,8 @@ func (p *QliksensePreflight) CheckDns(namespace string, kubeConfigContents []byt
|
||||
podName := "pf-pod-1"
|
||||
|
||||
if !cleanup {
|
||||
p.CG.LogVerboseMessage("Preflight DNS check: \n")
|
||||
p.CG.LogVerboseMessage("------------------- \n")
|
||||
fmt.Print("Preflight DNS check... ")
|
||||
p.CG.LogVerboseMessage("\n------------------- \n")
|
||||
}
|
||||
clientset, _, err := p.CG.GetK8SClientSet(kubeConfigContents, "")
|
||||
if err != nil {
|
||||
|
||||
@@ -22,8 +22,8 @@ const (
|
||||
|
||||
func (qp *QliksensePreflight) CheckMongo(kubeConfigContents []byte, namespace string, preflightOpts *PreflightOptions, cleanup bool) error {
|
||||
if !cleanup {
|
||||
qp.CG.LogVerboseMessage("Preflight mongodb check: \n")
|
||||
qp.CG.LogVerboseMessage("------------------------ \n")
|
||||
fmt.Print("Preflight mongodb check... ")
|
||||
qp.CG.LogVerboseMessage("\n------------------------ \n")
|
||||
}
|
||||
var currentCR *qapi.QliksenseCR
|
||||
var err error
|
||||
@@ -59,10 +59,10 @@ func (qp *QliksensePreflight) CheckMongo(kubeConfigContents []byte, namespace st
|
||||
if !cleanup {
|
||||
qp.CG.LogVerboseMessage("MongodbUrl: %s\n", preflightOpts.MongoOptions.MongodbUrl)
|
||||
|
||||
// if mongoDbUrl is empty, abort check
|
||||
// if mongodbUrl is empty, abort check
|
||||
if preflightOpts.MongoOptions.MongodbUrl == "" {
|
||||
qp.CG.LogVerboseMessage("Mongodb Url is empty, hence aborting preflight check\n")
|
||||
return errors.New("MongoDbUrl is empty")
|
||||
return errors.New("MongodbUrl is empty")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,6 @@ type PreflightOptions struct {
|
||||
MongoOptions *MongoOptions
|
||||
}
|
||||
|
||||
// // LogVerboseMessage logs a verbose message
|
||||
// func (p *PreflightOptions) LogVerboseMessage(strMessage string, args ...interface{}) {
|
||||
// if p.Verbose || os.Getenv("QLIKSENSE_DEBUG") == "true" {
|
||||
// fmt.Printf(strMessage, args...)
|
||||
// }
|
||||
// }
|
||||
|
||||
type MongoOptions struct {
|
||||
MongodbUrl string
|
||||
CaCertFile string
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
func (qp *QliksensePreflight) CheckCreateRole(namespace string, cleanup bool) error {
|
||||
// create a Role
|
||||
if !cleanup {
|
||||
qp.CG.LogVerboseMessage("Preflight role check: \n")
|
||||
qp.CG.LogVerboseMessage("--------------------- \n")
|
||||
fmt.Print("Preflight role check... ")
|
||||
qp.CG.LogVerboseMessage("\n--------------------- \n")
|
||||
}
|
||||
err := qp.checkCreateEntity(namespace, "Role", cleanup)
|
||||
if err != nil {
|
||||
@@ -30,8 +30,8 @@ func (qp *QliksensePreflight) CheckCreateRole(namespace string, cleanup bool) er
|
||||
func (qp *QliksensePreflight) CheckCreateRoleBinding(namespace string, cleanup bool) error {
|
||||
// create a RoleBinding
|
||||
if !cleanup {
|
||||
qp.CG.LogVerboseMessage("Preflight rolebinding check: \n")
|
||||
qp.CG.LogVerboseMessage("---------------------------- \n")
|
||||
fmt.Print("Preflight rolebinding check... ")
|
||||
qp.CG.LogVerboseMessage("\n---------------------------- \n")
|
||||
}
|
||||
err := qp.checkCreateEntity(namespace, "RoleBinding", cleanup)
|
||||
if err != nil {
|
||||
@@ -46,8 +46,8 @@ func (qp *QliksensePreflight) CheckCreateRoleBinding(namespace string, cleanup b
|
||||
func (qp *QliksensePreflight) CheckCreateServiceAccount(namespace string, cleanup bool) error {
|
||||
// create a service account
|
||||
if !cleanup {
|
||||
qp.CG.LogVerboseMessage("Preflight serviceaccount check: \n")
|
||||
qp.CG.LogVerboseMessage("------------------------------- \n")
|
||||
fmt.Print("Preflight serviceaccount check... ")
|
||||
qp.CG.LogVerboseMessage("\n------------------------------- \n")
|
||||
}
|
||||
err := qp.checkCreateEntity(namespace, "ServiceAccount", cleanup)
|
||||
if err != nil {
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func (p *QliksensePreflight) CheckK8sVersion(namespace string, kubeConfigContents []byte) error {
|
||||
p.CG.LogVerboseMessage("Preflight kubernetes version check: \n")
|
||||
p.CG.LogVerboseMessage("----------------------------------- \n")
|
||||
fmt.Print("Preflight kubernetes version check... ")
|
||||
p.CG.LogVerboseMessage("\n----------------------------------- \n")
|
||||
var currentVersion *semver.Version
|
||||
|
||||
clientset, _, err := p.CG.GetK8SClientSet(kubeConfigContents, "")
|
||||
|
||||
Reference in New Issue
Block a user