Skip to content

Commit

Permalink
add some experimental debugging files
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 8, 2024
1 parent e1cc7b7 commit 65fc016
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 9 deletions.
49 changes: 49 additions & 0 deletions experiments/debug_pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: v1
kind: Pod
metadata:
name: debug-adaravis
labels:
is_ioc: "true"
spec:
serviceAccountName: default-full-access-mounted
containers:
- name: debug-adaravis
image: ghcr.io/epics-containers/ioc-adaravis-developer:2024.11.1
command:
- bash
args:
- "-c"
- |
echo "keep running indefinetely"
while true; do sleep 5; done
resources:
limits:
memory: "2Gi"
cpu: "4"
requests:
memory: "1Gi"
cpu: "1"

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: beamline
operator: In
values:
- bl47p

tolerations:
- key: beamline
operator: Equal
value: bl47p
effect: NoSchedule
- key: location
operator: Equal
value: bl47p
effect: NoSchedule
- key: nodetype
operator: Equal
value: training-rig
effect: NoSchedule
59 changes: 59 additions & 0 deletions experiments/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python

"""
Prints out some information about the pods in a namespace
"""

import argparse

from kubernetes import client, config


def get_ioc_ips(v1: client.CoreV1Api):
"""Get the list cluster IPs of IOCs running in a namespace
Args:
v1: kubernetes client
namespace: namespace to get the IOCs from
"""
ips = set()

# get the current namespace
ns_path = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
with open(ns_path) as f:
current_namespace = f.read().strip()

# get the pods in the namespace
ret = v1.list_namespaced_pod(current_namespace)
for pod in ret.items:
print(pod.metadata.name, pod.status.pod_ip)
if "is_ioc" in pod.metadata.labels:
ips.add(pod.status.pod_ip)

return ips


def main():
args = parse_args()

# configure K8S and make a Core API client
config.load_incluster_config()
v1 = client.CoreV1Api()

ips = get_ioc_ips(v1)
ipstr = " ".join(ips)

command = f'/epics/ca-gateway/bin/linux-x86_64/gateway -sport {args.port} -cip "{ipstr}" -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1'

# print(f"Running command: {command}")
# subprocess.run(["bash", "-c", command], check=True)


def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=5064)
return parser.parse_args()


if __name__ == "__main__":
main()
15 changes: 7 additions & 8 deletions services/cagateway/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
location: bl47p
rollme: goWO0
spec:
serviceAccountName: default-full-access-mounted
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand All @@ -38,14 +39,12 @@ spec:
- bash
args:
- "-c"
- "/epics/gateway -sport {{ .Values.ca_port }} -cip 172.23.255.255 -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1"
- "python3 /launch_gateway.py --port {{ .Values.ca_port }} --namespace ${MY_POD_NAMESPACE}"
env:
- name: IOC_NAME
value: {{ .Release.Name }}
- name: IOC_LOCATION
value: bl47p
- name: IOC_GROUP
value: p47
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: {{ .Values.image }}
imagePullPolicy: Always
name: {{ .Release.Name }}
Expand All @@ -63,7 +62,7 @@ spec:
volumeMounts:
- mountPath: /config
name: config-volume
hostNetwork: true
hostNetwork: false
restartPolicy: Always
terminationGracePeriodSeconds: 3
tolerations:
Expand Down
2 changes: 1 addition & 1 deletion services/cagateway/values.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
image: ghcr.io/epics-containers/docker-ca-gateway-debug:2.1.3ec1
image: ghcr.io/epics-containers/docker-ca-gateway-debug:2.1.3ec2b4
ca_port: 9064

0 comments on commit 65fc016

Please sign in to comment.