# AffinityV1 Properties

- Package: [Aspire.Hosting.Kubernetes](/reference/api/csharp/aspire.hosting.kubernetes.md)
- Type: [AffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/affinityv1.md)
- Kind: `Properties`
- Members: `3`

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.

## NodeAffinity

- Name: `NodeAffinity`
- Modifiers: `get; set`
- Returns: [NodeAffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/nodeaffinityv1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/Resources/AffinityV1.cs)

Represents the node affinity property that defines node affinity scheduling rules. This property allows specifying preferred or required nodes for scheduling pods.

```csharp
public NodeAffinityV1 NodeAffinity { get; set; }
```

## PodAffinity

- Name: `PodAffinity`
- Modifiers: `get; set`
- Returns: [PodAffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/podaffinityv1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/Resources/AffinityV1.cs)

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.

```csharp
public PodAffinityV1 PodAffinity { get; set; }
```

## PodAntiAffinity

- Name: `PodAntiAffinity`
- Modifiers: `get; set`
- Returns: [PodAntiAffinityV1](/reference/api/csharp/aspire.hosting.kubernetes/podantiaffinityv1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/Resources/AffinityV1.cs)

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.

```csharp
public PodAntiAffinityV1 PodAntiAffinity { get; set; }
```
