mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-06-06 08:23:19 +00:00
Compare commits
54 Commits
28.0-dev28
...
28.0-dev32
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2a4af8600 | ||
|
|
60e7890e23 | ||
|
|
f19c2f08c3 | ||
|
|
d8c0132a98 | ||
|
|
c5a36a494a | ||
|
|
a54cb917d0 | ||
|
|
0ef16bd55a | ||
|
|
de42de9d62 | ||
|
|
026745ac8e | ||
|
|
5e07924aca | ||
|
|
77078e78d1 | ||
|
|
727d75bccc | ||
|
|
d987bb17d2 | ||
|
|
89946041a1 | ||
|
|
b919c93f28 | ||
|
|
eac751190d | ||
|
|
2bc2051a46 | ||
|
|
89ad4e0f3a | ||
|
|
72f4753620 | ||
|
|
4badaadcc1 | ||
|
|
3f01f20f0c | ||
|
|
1fbb00f8f0 | ||
|
|
da7d3590fc | ||
|
|
256006ca3e | ||
|
|
213528c619 | ||
|
|
8b47dba05d | ||
|
|
5e5d5de91a | ||
|
|
680ea71958 | ||
|
|
5fb5dbbbf5 | ||
|
|
b3fe448ff1 | ||
|
|
101a54e8da | ||
|
|
3308cab826 | ||
|
|
5fdd8288f4 | ||
|
|
4cb32b40e6 | ||
|
|
afa81c7ec2 | ||
|
|
e84c7d3310 | ||
|
|
7d0a90cb78 | ||
|
|
24f79922e9 | ||
|
|
c3995009ee | ||
|
|
6e9fe2986e | ||
|
|
603240fedb | ||
|
|
e61871a68e | ||
|
|
379af59f07 | ||
|
|
ef9afe31a4 | ||
|
|
dca636b0fd | ||
|
|
9b72cc7aa6 | ||
|
|
d3c023b3ba | ||
|
|
5f2a4deb19 | ||
|
|
91f290987e | ||
|
|
2f3215b71a | ||
|
|
2e87a01346 | ||
|
|
453003bf14 | ||
|
|
80ca377668 | ||
|
|
d21297bc9c |
@@ -24,7 +24,6 @@
|
|||||||
"redactHeaderContent": "User-Header[REDACTED]",
|
"redactHeaderContent": "User-Header[REDACTED]",
|
||||||
"redactBodyContent": "{ \"User\": \"[REDACTED]\" }",
|
"redactBodyContent": "{ \"User\": \"[REDACTED]\" }",
|
||||||
"regexMaskingBodyContent": "[REDACTED]",
|
"regexMaskingBodyContent": "[REDACTED]",
|
||||||
"minimumEntries": 25,
|
|
||||||
"greenFilterColor": "rgb(210, 250, 210)",
|
"greenFilterColor": "rgb(210, 250, 210)",
|
||||||
"redFilterColor": "rgb(250, 214, 220)",
|
"redFilterColor": "rgb(250, 214, 220)",
|
||||||
"bodyJsonClass": ".hljs",
|
"bodyJsonClass": ".hljs",
|
||||||
|
|||||||
@@ -25,14 +25,16 @@ export function resizeToNormalMizu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function verifyMinimumEntries() {
|
export function verifyMinimumEntries() {
|
||||||
const minimumEntries = Cypress.env('minimumEntries');
|
const entriesSent = Cypress.env('entriesCount');
|
||||||
it(`Making sure that mizu shows at least ${minimumEntries} entries`, async function () {
|
const minimumEntries = Math.round((0.75 * entriesSent));
|
||||||
|
|
||||||
|
it(`Making sure that mizu shows at least ${minimumEntries} entries`, function () {
|
||||||
cy.get('#total-entries').then(number => {
|
cy.get('#total-entries').then(number => {
|
||||||
const getNum = () => {
|
const getNum = () => {
|
||||||
const numOfEntries = number.text();
|
return parseInt(number.text());
|
||||||
return parseInt(numOfEntries);
|
|
||||||
};
|
};
|
||||||
cy.wrap({there: getNum}).invoke('there').should('be.gte', minimumEntries);
|
|
||||||
|
cy.wrap({num: getNum}).invoke('num').should('be.gt', minimumEntries);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
||||||
import {verifyMinimumEntries} from "../testHelpers/TrafficHelper";
|
|
||||||
|
|
||||||
it('check', function () {
|
it('check', function () {
|
||||||
const podName = Cypress.env('name'), namespace = Cypress.env('namespace');
|
const podName = Cypress.env('name'), namespace = Cypress.env('namespace');
|
||||||
@@ -9,8 +8,6 @@ it('check', function () {
|
|||||||
cy.visit(`http://localhost:${port}`);
|
cy.visit(`http://localhost:${port}`);
|
||||||
cy.wait('@statusTap').its('response.statusCode').should('match', /^2\d{2}/);
|
cy.wait('@statusTap').its('response.statusCode').should('match', /^2\d{2}/);
|
||||||
|
|
||||||
verifyMinimumEntries();
|
|
||||||
|
|
||||||
cy.get('.podsCount').trigger('mouseover');
|
cy.get('.podsCount').trigger('mouseover');
|
||||||
findLineAndCheck(getExpectedDetailsDict(podName, namespace));
|
findLineAndCheck(getExpectedDetailsDict(podName, namespace));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,15 +2,12 @@ import {
|
|||||||
checkThatAllEntriesShown,
|
checkThatAllEntriesShown,
|
||||||
isValueExistsInElement,
|
isValueExistsInElement,
|
||||||
resizeToHugeMizu,
|
resizeToHugeMizu,
|
||||||
verifyMinimumEntries
|
|
||||||
} from "../testHelpers/TrafficHelper";
|
} from "../testHelpers/TrafficHelper";
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyMinimumEntries();
|
|
||||||
|
|
||||||
checkEntries();
|
checkEntries();
|
||||||
|
|
||||||
function checkEntries() {
|
function checkEntries() {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import {isValueExistsInElement, verifyMinimumEntries} from '../testHelpers/TrafficHelper';
|
import {isValueExistsInElement} from '../testHelpers/TrafficHelper';
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyMinimumEntries();
|
|
||||||
|
|
||||||
isValueExistsInElement(false, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
isValueExistsInElement(false, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
||||||
isValueExistsInElement(false, Cypress.env('redactBodyContent'), Cypress.env('bodyJsonClass'));
|
isValueExistsInElement(false, Cypress.env('redactBodyContent'), Cypress.env('bodyJsonClass'));
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import {isValueExistsInElement, verifyMinimumEntries} from '../testHelpers/TrafficHelper';
|
import {isValueExistsInElement} from '../testHelpers/TrafficHelper';
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyMinimumEntries();
|
|
||||||
|
|
||||||
isValueExistsInElement(true, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
isValueExistsInElement(true, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
||||||
isValueExistsInElement(true, Cypress.env('redactBodyContent'), Cypress.env('bodyJsonClass'));
|
isValueExistsInElement(true, Cypress.env('redactBodyContent'), Cypress.env('bodyJsonClass'));
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import {isValueExistsInElement, verifyMinimumEntries} from "../testHelpers/TrafficHelper";
|
import {isValueExistsInElement} from "../testHelpers/TrafficHelper";
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyMinimumEntries();
|
|
||||||
|
|
||||||
isValueExistsInElement(true, Cypress.env('regexMaskingBodyContent'), Cypress.env('bodyJsonClass'));
|
isValueExistsInElement(true, Cypress.env('regexMaskingBodyContent'), Cypress.env('bodyJsonClass'));
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func TestTap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/UiTest.js\"")
|
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/UiTest.js\" --env entriesCount=%d", entriesCount))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/up9inc/mizu/shared"
|
|
||||||
rbac "k8s.io/api/rbac/v1"
|
rbac "k8s.io/api/rbac/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
@@ -17,6 +17,11 @@ import (
|
|||||||
"github.com/up9inc/mizu/shared/semver"
|
"github.com/up9inc/mizu/shared/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
//go:embed permissionFiles
|
||||||
|
embedFS embed.FS
|
||||||
|
)
|
||||||
|
|
||||||
func runMizuCheck() {
|
func runMizuCheck() {
|
||||||
logger.Log.Infof("Mizu checks\n===================")
|
logger.Log.Infof("Mizu checks\n===================")
|
||||||
|
|
||||||
@@ -34,13 +39,8 @@ func runMizuCheck() {
|
|||||||
checkPassed = checkK8sTapPermissions(ctx, kubernetesProvider)
|
checkPassed = checkK8sTapPermissions(ctx, kubernetesProvider)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var isInstallCommand bool
|
|
||||||
if checkPassed {
|
if checkPassed {
|
||||||
checkPassed, isInstallCommand = checkMizuMode(ctx, kubernetesProvider)
|
checkPassed = checkK8sResources(ctx, kubernetesProvider)
|
||||||
}
|
|
||||||
|
|
||||||
if checkPassed {
|
|
||||||
checkPassed = checkK8sResources(ctx, kubernetesProvider, isInstallCommand)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if checkPassed {
|
if checkPassed {
|
||||||
@@ -75,27 +75,6 @@ func checkKubernetesApi() (*kubernetes.Provider, *semver.SemVersion, bool) {
|
|||||||
return kubernetesProvider, kubernetesVersion, true
|
return kubernetesProvider, kubernetesVersion, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkMizuMode(ctx context.Context, kubernetesProvider *kubernetes.Provider) (bool, bool) {
|
|
||||||
logger.Log.Infof("\nmode\n--------------------")
|
|
||||||
|
|
||||||
if exist, err := kubernetesProvider.DoesDeploymentExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName); err != nil {
|
|
||||||
logger.Log.Errorf("%v can't check mizu command, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
|
||||||
return false, false
|
|
||||||
} else if exist {
|
|
||||||
logger.Log.Infof("%v mizu running with install command", fmt.Sprintf(uiUtils.Green, "√"))
|
|
||||||
return true, true
|
|
||||||
} else if exist, err = kubernetesProvider.DoesPodExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName); err != nil {
|
|
||||||
logger.Log.Errorf("%v can't check mizu command, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
|
||||||
return false, false
|
|
||||||
} else if exist {
|
|
||||||
logger.Log.Infof("%v mizu running with tap command", fmt.Sprintf(uiUtils.Green, "√"))
|
|
||||||
return true, false
|
|
||||||
} else {
|
|
||||||
logger.Log.Infof("%v mizu is not running", fmt.Sprintf(uiUtils.Red, "✗"))
|
|
||||||
return false, false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkKubernetesVersion(kubernetesVersion *semver.SemVersion) bool {
|
func checkKubernetesVersion(kubernetesVersion *semver.SemVersion) bool {
|
||||||
logger.Log.Infof("\nkubernetes-version\n--------------------")
|
logger.Log.Infof("\nkubernetes-version\n--------------------")
|
||||||
|
|
||||||
@@ -179,7 +158,7 @@ func checkPortForward(serverUrl string, kubernetesProvider *kubernetes.Provider)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkK8sResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, isInstallCommand bool) bool {
|
func checkK8sResources(ctx context.Context, kubernetesProvider *kubernetes.Provider) bool {
|
||||||
logger.Log.Infof("\nk8s-components\n--------------------")
|
logger.Log.Infof("\nk8s-components\n--------------------")
|
||||||
|
|
||||||
exist, err := kubernetesProvider.DoesNamespaceExist(ctx, config.Config.MizuResourcesNamespace)
|
exist, err := kubernetesProvider.DoesNamespaceExist(ctx, config.Config.MizuResourcesNamespace)
|
||||||
@@ -208,52 +187,27 @@ func checkK8sResources(ctx context.Context, kubernetesProvider *kubernetes.Provi
|
|||||||
exist, err = kubernetesProvider.DoesServiceExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName)
|
exist, err = kubernetesProvider.DoesServiceExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName)
|
||||||
allResourcesExist = checkResourceExist(kubernetes.ApiServerPodName, "service", exist, err) && allResourcesExist
|
allResourcesExist = checkResourceExist(kubernetes.ApiServerPodName, "service", exist, err) && allResourcesExist
|
||||||
|
|
||||||
if isInstallCommand {
|
allResourcesExist = checkPodResourcesExist(ctx, kubernetesProvider) && allResourcesExist
|
||||||
allResourcesExist = checkInstallResourcesExist(ctx, kubernetesProvider) && allResourcesExist
|
|
||||||
} else {
|
|
||||||
allResourcesExist = checkTapResourcesExist(ctx, kubernetesProvider) && allResourcesExist
|
|
||||||
}
|
|
||||||
|
|
||||||
return allResourcesExist
|
return allResourcesExist
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkInstallResourcesExist(ctx context.Context, kubernetesProvider *kubernetes.Provider) bool {
|
func checkPodResourcesExist(ctx context.Context, kubernetesProvider *kubernetes.Provider) bool {
|
||||||
exist, err := kubernetesProvider.DoesRoleExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.DaemonRoleName)
|
if pods, err := kubernetesProvider.ListPodsByAppLabel(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName); err != nil {
|
||||||
installResourcesExist := checkResourceExist(kubernetes.DaemonRoleName, "role", exist, err)
|
logger.Log.Errorf("%v error checking if '%v' pod is running, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), kubernetes.ApiServerPodName, err)
|
||||||
|
|
||||||
exist, err = kubernetesProvider.DoesRoleBindingExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.DaemonRoleBindingName)
|
|
||||||
installResourcesExist = checkResourceExist(kubernetes.DaemonRoleBindingName, "role binding", exist, err) && installResourcesExist
|
|
||||||
|
|
||||||
exist, err = kubernetesProvider.DoesPersistentVolumeClaimExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.PersistentVolumeClaimName)
|
|
||||||
installResourcesExist = checkResourceExist(kubernetes.PersistentVolumeClaimName, "persistent volume claim", exist, err) && installResourcesExist
|
|
||||||
|
|
||||||
exist, err = kubernetesProvider.DoesDeploymentExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName)
|
|
||||||
installResourcesExist = checkResourceExist(kubernetes.ApiServerPodName, "deployment", exist, err) && installResourcesExist
|
|
||||||
|
|
||||||
return installResourcesExist
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkTapResourcesExist(ctx context.Context, kubernetesProvider *kubernetes.Provider) bool {
|
|
||||||
exist, err := kubernetesProvider.DoesPodExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName)
|
|
||||||
tapResourcesExist := checkResourceExist(kubernetes.ApiServerPodName, "pod", exist, err)
|
|
||||||
|
|
||||||
if !tapResourcesExist {
|
|
||||||
return false
|
return false
|
||||||
}
|
} else if len(pods) == 0 {
|
||||||
|
logger.Log.Errorf("%v '%v' pod doesn't exist", fmt.Sprintf(uiUtils.Red, "✗"), kubernetes.ApiServerPodName)
|
||||||
if pod, err := kubernetesProvider.GetPod(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName); err != nil {
|
|
||||||
logger.Log.Errorf("%v error checking if '%v' pod exists, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), kubernetes.ApiServerPodName, err)
|
|
||||||
return false
|
return false
|
||||||
} else if kubernetes.IsPodRunning(pod) {
|
} else if !kubernetes.IsPodRunning(&pods[0]) {
|
||||||
logger.Log.Infof("%v '%v' pod running", fmt.Sprintf(uiUtils.Green, "√"), kubernetes.ApiServerPodName)
|
|
||||||
} else {
|
|
||||||
logger.Log.Errorf("%v '%v' pod not running", fmt.Sprintf(uiUtils.Red, "✗"), kubernetes.ApiServerPodName)
|
logger.Log.Errorf("%v '%v' pod not running", fmt.Sprintf(uiUtils.Red, "✗"), kubernetes.ApiServerPodName)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
tapperRegex := regexp.MustCompile(fmt.Sprintf("^%s.*", kubernetes.TapperPodName))
|
logger.Log.Infof("%v '%v' pod running", fmt.Sprintf(uiUtils.Green, "√"), kubernetes.ApiServerPodName)
|
||||||
if pods, err := kubernetesProvider.ListAllPodsMatchingRegex(ctx, tapperRegex, []string{config.Config.MizuResourcesNamespace}); err != nil {
|
|
||||||
logger.Log.Errorf("%v error listing '%v' pods, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), kubernetes.TapperPodName, err)
|
if pods, err := kubernetesProvider.ListPodsByAppLabel(ctx, config.Config.MizuResourcesNamespace, kubernetes.TapperPodName); err != nil {
|
||||||
|
logger.Log.Errorf("%v error checking if '%v' pods are running, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), kubernetes.TapperPodName, err)
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
tappers := 0
|
tappers := 0
|
||||||
@@ -294,12 +248,12 @@ func checkK8sTapPermissions(ctx context.Context, kubernetesProvider *kubernetes.
|
|||||||
|
|
||||||
var filePath string
|
var filePath string
|
||||||
if config.Config.IsNsRestrictedMode() {
|
if config.Config.IsNsRestrictedMode() {
|
||||||
filePath = "./examples/roles/permissions-ns-tap.yaml"
|
filePath = "permissionFiles/permissions-ns-tap.yaml"
|
||||||
} else {
|
} else {
|
||||||
filePath = "./examples/roles/permissions-all-namespaces-tap.yaml"
|
filePath = "permissionFiles/permissions-all-namespaces-tap.yaml"
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := shared.ReadFromFile(filePath)
|
data, err := embedFS.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log.Errorf("%v error while checking kubernetes permissions, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
logger.Log.Errorf("%v error while checking kubernetes permissions, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ var installCmd = &cobra.Command{
|
|||||||
logger.Log.Infof("This command has been deprecated, please use helm as described below.\n\n")
|
logger.Log.Infof("This command has been deprecated, please use helm as described below.\n\n")
|
||||||
|
|
||||||
logger.Log.Infof("To install stable build of Mizu on your cluster using helm, run the following command:")
|
logger.Log.Infof("To install stable build of Mizu on your cluster using helm, run the following command:")
|
||||||
logger.Log.Infof(" helm install mizu mizu --repo https://static.up9.com/mizu/helm --namespace=mizu --create-namespace\n\n")
|
logger.Log.Infof(" helm install mizu up9mizu --repo https://static.up9.com/mizu/helm --namespace=mizu --create-namespace\n\n")
|
||||||
|
|
||||||
logger.Log.Infof("To install development build of Mizu on your cluster using helm, run the following command:")
|
logger.Log.Infof("To install development build of Mizu on your cluster using helm, run the following command:")
|
||||||
logger.Log.Infof(" helm install mizu mizu --repo https://static.up9.com/mizu/helm-develop --namespace=mizu --create-namespace\n")
|
logger.Log.Infof(" helm install mizu up9mizu --repo https://static.up9.com/mizu/helm-develop --namespace=mizu --create-namespace\n")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -85,4 +85,4 @@ By default Mizu requires cluster-wide permissions.
|
|||||||
If these are not available to the user, it is possible to run Mizu in namespace-restricted mode which has a reduced set of requirements.
|
If these are not available to the user, it is possible to run Mizu in namespace-restricted mode which has a reduced set of requirements.
|
||||||
This is done by by setting the `mizu-resources-namespace` config option. See [configuration](CONFIGURATION.md) for instructions.
|
This is done by by setting the `mizu-resources-namespace` config option. See [configuration](CONFIGURATION.md) for instructions.
|
||||||
|
|
||||||
The different requirements are listed in [the example roles dir](../examples/roles)
|
The different requirements are listed in [the permission templates dir](../cli/cmd/permissionFiles)
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package shared
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ReadFromFile(path string) ([]byte, error) {
|
|
||||||
reader, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(reader)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return data, nil
|
|
||||||
}
|
|
||||||
@@ -489,11 +489,6 @@ func (provider *Provider) DoesDeploymentExist(ctx context.Context, namespace str
|
|||||||
return provider.doesResourceExist(deploymentResource, err)
|
return provider.doesResourceExist(deploymentResource, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *Provider) DoesPodExist(ctx context.Context, namespace string, name string) (bool, error) {
|
|
||||||
podResource, err := provider.clientSet.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{})
|
|
||||||
return provider.doesResourceExist(podResource, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (provider *Provider) DoesServiceExist(ctx context.Context, namespace string, name string) (bool, error) {
|
func (provider *Provider) DoesServiceExist(ctx context.Context, namespace string, name string) (bool, error) {
|
||||||
serviceResource, err := provider.clientSet.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{})
|
serviceResource, err := provider.clientSet.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{})
|
||||||
return provider.doesResourceExist(serviceResource, err)
|
return provider.doesResourceExist(serviceResource, err)
|
||||||
@@ -1043,6 +1038,15 @@ func (provider *Provider) ListAllRunningPodsMatchingRegex(ctx context.Context, r
|
|||||||
return matchingPods, nil
|
return matchingPods, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func(provider *Provider) ListPodsByAppLabel(ctx context.Context, namespaces string, labelName string) ([]core.Pod, error) {
|
||||||
|
pods, err := provider.clientSet.CoreV1().Pods(namespaces).List(ctx, metav1.ListOptions{LabelSelector: fmt.Sprintf("app=%s", labelName)})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pods.Items, err
|
||||||
|
}
|
||||||
|
|
||||||
func (provider *Provider) ListAllNamespaces(ctx context.Context) ([]core.Namespace, error) {
|
func (provider *Provider) ListAllNamespaces(ctx context.Context) ([]core.Namespace, error) {
|
||||||
namespaces, err := provider.clientSet.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})
|
namespaces, err := provider.clientSet.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user