# AffinityV1

- Kind: `class`
- Package: [Aspire.Hosting.Kubernetes](/reference/api/csharp/aspire.hosting.kubernetes.md)
- Version: `13.3.0-preview.1.26254.5`
- Namespace: `Aspire.Hosting.Kubernetes.Resources`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/Resources/AffinityV1.cs)

Represents the affinity configuration for a pod, including node affinity, pod affinity, and pod anti-affinity settings. This class defines rules to influence pod scheduling based on various criteria, such as node labels or inter-pod relationships.

## Definition

```csharp
namespace Aspire.Hosting.Kubernetes.Resources;

public sealed class AffinityV1
{
    // ...
}
```

## Constructors

- [AffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/affinityv1/constructors.md#constructor)

## Properties

- [NodeAffinity](/reference/api/csharp/aspire.hosting.kubernetes/affinityv1/properties.md#nodeaffinity) : [NodeAffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/nodeaffinityv1.md) `get; set` -- Represents the node affinity property that defines node affinity scheduling rules. This property allows specifying preferred or required nodes for scheduling pods.
- [PodAffinity](/reference/api/csharp/aspire.hosting.kubernetes/affinityv1/properties.md#podaffinity) : [PodAffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/podaffinityv1.md) `get; set` -- Represents inter-pod affinity scheduling rules to influence the placement of pods relative to other pods. This property defines constraints for scheduling pods to be either co-located or not co-located with specified pods, based on labels and topology.
- [PodAntiAffinity](/reference/api/csharp/aspire.hosting.kubernetes/affinityv1/properties.md#podantiaffinity) : [PodAntiAffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/podantiaffinityv1.md) `get; set` -- Represents the pod anti-affinity configuration for scheduling in Kubernetes. Pod anti-affinity allows specifying rules to avoid placing certain pods together on the same node or in a specific topology domain. This ensures Pods are scheduled in a manner that prevents tightly coupling their placement.
