mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-26 13:04:13 +00:00
Add GetDeployment
This commit is contained in:
@@ -949,20 +949,28 @@ func (provider *Provider) ApplyMizuTapperDaemonSet(ctx context.Context, namespac
|
|||||||
})
|
})
|
||||||
podTemplate.WithSpec(podSpec)
|
podTemplate.WithSpec(podSpec)
|
||||||
|
|
||||||
ownerReferences := applyconfmeta.OwnerReference()
|
ownerReferences := make([]*applyconfmeta.OwnerReferenceApplyConfiguration, 0)
|
||||||
// ownerReferences.WithAPIVersion()
|
deployment, err := provider.GetDeployment(ctx, namespace, "mizu-api-server")
|
||||||
ownerReferences.WithKind("DaemonSet")
|
if err == nil {
|
||||||
ownerReferences.WithName(daemonSetName)
|
logger.Log.Info("DEBUG adding owner %+v", deployment)
|
||||||
// ownerReferences.WithUID()
|
ownerReference := applyconfmeta.OwnerReference()
|
||||||
// ownerReferences.WithController()
|
ownerReference.WithAPIVersion("apps/v1") // get from deployment obj. deployment.APIVersion is empty. ¯\_(ツ)_/¯
|
||||||
// ownerReferences.WithBlockOwnerDeletion()
|
ownerReference.WithKind("Deployment") // get from deployment obj. deployment.Kind is empty. ¯\_(ツ)_/¯
|
||||||
|
ownerReference.WithName(deployment.Name)
|
||||||
|
ownerReference.WithUID(deployment.UID)
|
||||||
|
ownerReferences = append(ownerReferences, ownerReference)
|
||||||
|
// ownerReferences.WithController() // not sure whether or not to use this
|
||||||
|
// ownerReferences.WithBlockOwnerDeletion() // not sure whether or not to use this
|
||||||
|
} else {
|
||||||
|
logger.Log.Infof("DEBUG error getting deployment %+v", err)
|
||||||
|
}
|
||||||
|
|
||||||
labelSelector := applyconfmeta.LabelSelector()
|
labelSelector := applyconfmeta.LabelSelector()
|
||||||
labelSelector.WithMatchLabels(map[string]string{"app": tapperPodName})
|
labelSelector.WithMatchLabels(map[string]string{"app": tapperPodName})
|
||||||
|
|
||||||
daemonSet := applyconfapp.DaemonSet(daemonSetName, namespace)
|
daemonSet := applyconfapp.DaemonSet(daemonSetName, namespace)
|
||||||
daemonSet.
|
daemonSet.
|
||||||
WithOwnerReferences(ownerReferences).
|
WithOwnerReferences(ownerReferences...).
|
||||||
WithLabels(map[string]string{
|
WithLabels(map[string]string{
|
||||||
LabelManagedBy: provider.managedBy,
|
LabelManagedBy: provider.managedBy,
|
||||||
LabelCreatedBy: provider.createdBy,
|
LabelCreatedBy: provider.createdBy,
|
||||||
@@ -1001,6 +1009,10 @@ func (provider *Provider) GetPod(ctx context.Context, namespaces string, podName
|
|||||||
return provider.clientSet.CoreV1().Pods(namespaces).Get(ctx, podName, metav1.GetOptions{})
|
return provider.clientSet.CoreV1().Pods(namespaces).Get(ctx, podName, metav1.GetOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (provider *Provider) GetDeployment(ctx context.Context, namespace string, deploymentName string) (*v1.Deployment, error) {
|
||||||
|
return provider.clientSet.AppsV1().Deployments(namespace).Get(ctx, deploymentName, metav1.GetOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
func (provider *Provider) ListAllRunningPodsMatchingRegex(ctx context.Context, regex *regexp.Regexp, namespaces []string) ([]core.Pod, error) {
|
func (provider *Provider) ListAllRunningPodsMatchingRegex(ctx context.Context, regex *regexp.Regexp, namespaces []string) ([]core.Pod, error) {
|
||||||
pods, err := provider.ListAllPodsMatchingRegex(ctx, regex, namespaces)
|
pods, err := provider.ListAllPodsMatchingRegex(ctx, regex, namespaces)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user