MCPcopy Index your code
hub / github.com/kubernetes/sample-controller / newDeployment

Function newDeployment

controller.go:388–421  ·  view source on GitHub ↗

newDeployment creates a new Deployment for a Foo resource. It also sets the appropriate OwnerReferences on the resource so handleObject can discover the Foo resource that 'owns' it.

(foo *samplev1alpha1.Foo)

Source from the content-addressed store, hash-verified

386// the appropriate OwnerReferences on the resource so handleObject can discover
387// the Foo resource that 'owns' it.
388func newDeployment(foo *samplev1alpha1.Foo) *appsv1.Deployment {
389 labels := map[string]string{
390 "app": "nginx",
391 "controller": foo.Name,
392 }
393 return &appsv1.Deployment{
394 ObjectMeta: metav1.ObjectMeta{
395 Name: foo.Spec.DeploymentName,
396 Namespace: foo.Namespace,
397 OwnerReferences: []metav1.OwnerReference{
398 *metav1.NewControllerRef(foo, samplev1alpha1.SchemeGroupVersion.WithKind("Foo")),
399 },
400 },
401 Spec: appsv1.DeploymentSpec{
402 Replicas: foo.Spec.Replicas,
403 Selector: &metav1.LabelSelector{
404 MatchLabels: labels,
405 },
406 Template: corev1.PodTemplateSpec{
407 ObjectMeta: metav1.ObjectMeta{
408 Labels: labels,
409 },
410 Spec: corev1.PodSpec{
411 Containers: []corev1.Container{
412 {
413 Name: "nginx",
414 Image: "nginx:latest",
415 },
416 },
417 },
418 },
419 },
420 }
421}

Callers 5

syncHandlerMethod · 0.85
TestCreatesDeploymentFunction · 0.85
TestDoNothingFunction · 0.85
TestUpdateDeploymentFunction · 0.85
TestNotControlledByUsFunction · 0.85

Calls 1

WithKindMethod · 0.80

Tested by 4

TestCreatesDeploymentFunction · 0.68
TestDoNothingFunction · 0.68
TestUpdateDeploymentFunction · 0.68
TestNotControlledByUsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…