diff --git a/charts/selenoid/.helmignore b/charts/selenoid/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/selenoid/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/selenoid/Chart.yaml b/charts/selenoid/Chart.yaml new file mode 100644 index 0000000..bc37bef --- /dev/null +++ b/charts/selenoid/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: selenoid +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.11.3" diff --git a/charts/selenoid/templates/NOTES.txt b/charts/selenoid/templates/NOTES.txt new file mode 100644 index 0000000..bbe130d --- /dev/null +++ b/charts/selenoid/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "selenoid.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "selenoid.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "selenoid.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "selenoid.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/selenoid/templates/_helpers.tpl b/charts/selenoid/templates/_helpers.tpl new file mode 100644 index 0000000..1a94975 --- /dev/null +++ b/charts/selenoid/templates/_helpers.tpl @@ -0,0 +1,83 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "selenoid.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "selenoid.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "selenoid.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "selenoid.labels" -}} +helm.sh/chart: {{ include "selenoid.chart" . }} +{{ include "selenoid.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Common labels for UI +*/}} +{{- define "selenoidUI.labels" -}} +helm.sh/chart: {{ include "selenoid.chart" . }} +{{ include "selenoidUI.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + + +{{/* +Selector labels +*/}} +{{- define "selenoid.selectorLabels" -}} +app.kubernetes.io/name: {{ include "selenoid.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Selector labels for the UI +*/}} +{{- define "selenoidUI.selectorLabels" -}} +app.kubernetes.io/name: {{ include "selenoid.name" . }}-ui +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "selenoid.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "selenoid.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/selenoid/templates/selenoid-ui/deployment.yaml b/charts/selenoid/templates/selenoid-ui/deployment.yaml new file mode 100644 index 0000000..f21f6e7 --- /dev/null +++ b/charts/selenoid/templates/selenoid-ui/deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "selenoid.fullname" . }}-ui + labels: + {{- include "selenoidUI.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "selenoidUI.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "selenoidUI.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: aerokube/selenoid-ui + args: + - --selenoid-uri + - "http://{{ include "selenoid.fullname" . }}:4444" + imagePullPolicy: {{ .Values.image.pullPolicy }} + livenessProbe: + {{- toYaml .Values.ui.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.ui.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + ports: + - containerPort: 8080 + name: selenoid-ui + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/selenoid/templates/selenoid-ui/ingress.yaml b/charts/selenoid/templates/selenoid-ui/ingress.yaml new file mode 100644 index 0000000..96dbe91 --- /dev/null +++ b/charts/selenoid/templates/selenoid-ui/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "selenoid.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "selenoidUI.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }}-ui + port: + number: 8080 + {{- else }} + serviceName: {{ $fullName }}-ui + servicePort: 8080 + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/selenoid/templates/selenoid-ui/network-policies.yaml b/charts/selenoid/templates/selenoid-ui/network-policies.yaml new file mode 100644 index 0000000..8d98aa2 --- /dev/null +++ b/charts/selenoid/templates/selenoid-ui/network-policies.yaml @@ -0,0 +1,59 @@ +--- +kind: NetworkPolicy +apiVersion: networking.k8s.io/v1 +metadata: + name: {{ include "selenoid.fullname" . }} + labels: + {{- include "selenoid.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + {{- include "selenoid.selectorLabels" . | nindent 6 }} + ingress: + - {} + egress: + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + k8s-app: coredns + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + k8s-app: kubedns + - to: + - ipBlock: + cidr: 0.0.0.0/0 + except: + - 10.0.0.0/8 +#kind: NetworkPolicy +#apiVersion: networking.k8s.io/v1 +#metadata: +# name: default-deny-all +#spec: +# podSelector: {} +# policyTypes: +# - Egress +# - Ingress +--- +#kind: NetworkPolicy +#apiVersion: networking.k8s.io/v1 +#metadata: +# name: allow-internet-only +#spec: +# podSelector: {} +# policyTypes: +# - Egress +# egress: +# - to: +# - ipBlock: +# cidr: 0.0.0.0/0 +# except: +# - 10.0.0.0/8 +# - 192.168.0.0/16 +# - 172.16.0.0/20 + diff --git a/charts/selenoid/templates/selenoid-ui/service.yaml b/charts/selenoid/templates/selenoid-ui/service.yaml new file mode 100644 index 0000000..2db9f4e --- /dev/null +++ b/charts/selenoid/templates/selenoid-ui/service.yaml @@ -0,0 +1,16 @@ + +apiVersion: v1 +kind: Service +metadata: + name: {{ include "selenoid.fullname" . }}-ui + labels: + {{- include "selenoidUI.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: 8080 + targetPort: selenoid-ui + protocol: TCP + name: http + selector: + {{- include "selenoidUI.selectorLabels" . | nindent 4 }} diff --git a/charts/selenoid/templates/selenoid/config.yaml b/charts/selenoid/templates/selenoid/config.yaml new file mode 100644 index 0000000..2acbd72 --- /dev/null +++ b/charts/selenoid/templates/selenoid/config.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "selenoid.fullname" . }}-config + labels: + {{- include "selenoid.labels" . | nindent 4 }} +data: + browsers.json: | + { + "chrome": { + "default": "latest", + "versions": { + "latest": { + "image": "selenoid/chrome:latest", + "port": "4444", + "tmpfs": {"/tmp":"size=512m"} + } + } + }, + "firefox": { + "default": "latest", + "versions": { + "latest": { + "image": "selenoid/firefox:latest", + "port": "4444", + "path": "/wd/hub", + "tmpfs": {"/tmp":"size=512m"} + } + } + } + } diff --git a/charts/selenoid/templates/selenoid/deployment.yaml b/charts/selenoid/templates/selenoid/deployment.yaml new file mode 100644 index 0000000..c0e47c1 --- /dev/null +++ b/charts/selenoid/templates/selenoid/deployment.yaml @@ -0,0 +1,129 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "selenoid.fullname" . }} + labels: + {{- include "selenoid.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "selenoid.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "selenoid.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + startupProbe: + {{- toYaml .Values.startupProbe | nindent 12 }} + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: /etc/selenoid/browsers.json + subPath: browsers.json + - name: scripts + mountPath: /tmp/scripts/selenoid + subPath: selenoid + command: + - sh + args: + - /tmp/scripts/selenoid + ports: + - containerPort: 4444 + name: selenium + env: + - name: DOCKER_HOST + value: tcp://localhost:2375 + - name: dind + image: "{{ .Values.dind.registry }}/{{ .Values.dind.repository }}:{{ .Values.dind.tag }}" + imagePullPolicy: {{ .Values.dind.pullPolicy }} + command: + {{- range .Values.dind.command }} + - {{ . }} + {{- end }} + args: + {{- range .Values.dind.commandArgs }} + - {{ . }} + {{- end }} + {{- with .Values.dind.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + lifecycle: + preStop: + # wait for all running containers to have stopped, so the last build can finish before the runner is fully stopped. + exec: + command: ["/bin/sh","-c","while true; do sleep {{ .Values.dind.gracefulShutdownRetryPeriod }}; lastEventTime=$(docker -H tcp://localhost:2375 events --since={{ .Values.dind.gracefulShutdownRetryPeriod }}s --until=1s | wc -l); containersRunning=$(docker -H tcp://localhost:2375 ps -q | wc -l); if [ $containersRunning -eq 0 ] && [ $lastEventTime -eq 0 ]; then exit 0; fi; echo 'steps/containers running, retry'; done"] + livenessProbe: + exec: + command: + - docker + - -H + - tcp://localhost:2375 + - images + initialDelaySeconds: 5 + periodSeconds: 5 + readinessProbe: + exec: + command: + - docker + - -H + - tcp://localhost:2375 + - images + initialDelaySeconds: 5 + periodSeconds: 5 + {{- with .Values.dind.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.dind.extraVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ include "selenoid.fullname" . }}-config + - name: scripts + configMap: + name: {{ include "selenoid.fullname" . }}-scripts + - name: docker-storage + emptyDir: {} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/selenoid/templates/selenoid/script-configmap.yaml b/charts/selenoid/templates/selenoid/script-configmap.yaml new file mode 100644 index 0000000..b8d248c --- /dev/null +++ b/charts/selenoid/templates/selenoid/script-configmap.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "selenoid.fullname" . }}-scripts + labels: + {{- include "selenoid.labels" . | nindent 4 }} +data: + selenoid: |- + #!/usr/bin/sh + set -e + for i in `seq 0 100` + do wget 127.0.0.1:2375/version && break || echo waiting && sleep 5 + done + # -- This is supposed to get the docker API version + sed -E 's/.*"ApiVersion":"?([^,"]*)"?.*/\1/' version + images=$(cat /etc/selenoid/browsers.json | grep image | awk '{print $2}' | sed -e "s/\"//g" -e "s/,//g") + for image in $images; do + wget --header "Content-Type: application/json" \ + -O - --post-data="-" \ + 127.0.0.1:2375/v1.41/images/create?fromImage=$image + done + /usr/bin/selenoid -listen :4444 -conf /etc/selenoid/browsers.json diff --git a/charts/selenoid/templates/selenoid/service.yaml b/charts/selenoid/templates/selenoid/service.yaml new file mode 100644 index 0000000..11172e2 --- /dev/null +++ b/charts/selenoid/templates/selenoid/service.yaml @@ -0,0 +1,16 @@ + +apiVersion: v1 +kind: Service +metadata: + name: {{ include "selenoid.fullname" . }} + labels: + {{- include "selenoid.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: 4444 + targetPort: selenium + protocol: TCP + name: http + selector: + {{- include "selenoid.selectorLabels" . | nindent 4 }} diff --git a/charts/selenoid/todo.md b/charts/selenoid/todo.md new file mode 100644 index 0000000..c48819d --- /dev/null +++ b/charts/selenoid/todo.md @@ -0,0 +1,3 @@ +Network policies should + +Let the selenoid pod access the internet without letting access internal services diff --git a/charts/selenoid/values.yaml b/charts/selenoid/values.yaml new file mode 100644 index 0000000..5b33244 --- /dev/null +++ b/charts/selenoid/values.yaml @@ -0,0 +1,152 @@ +# Default values for selenoid. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: aerokube/selenoid + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +dind: + ## The official docker (dind) image, change tag to use a different version. + ## ref: https://hub.docker.com/r/library/docker/tags/ + ## + registry: docker.io + repository: docker + tag: 20-dind + pullPolicy: IfNotPresent + command: + - "dockerd" + commandArgs: + - "--host" + - "tcp://localhost:2375" + securityContext: + privileged: true + ## If you have declared extra volumes, mount them here, per the Pod Container's + ## "volumeMounts" section of dind container + ## + extraVolumeMounts: [] + # - name: storage + # mountPath: /var/lib/docker + # subPath: docker + resources: + {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + gracefulShutdownRetryPeriod: 60 +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + className: "" + annotations: + cert-manager.io/cluster-issuer: badhouseplants-issuer-http01 + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: selenoid-ui.badhouseplants.net + paths: + - path: / + pathType: ImplementationSpecific + tls: + - secretName: selenoid-ui.badhouseplants.net + hosts: + - selenoid-ui.badhouseplants.net + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi +startupProbe: + failureThreshold: 50 + periodSeconds: 10 + tcpSocket: + port: 4444 +livenessProbe: + tcpSocket: + port: 4444 +readinessProbe: + tcpSocket: + port: 4444 +ui: + livenessProbe: + tcpSocket: + port: 8080 + readinessProbe: + tcpSocket: + port: 8080 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# -name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {}