Skip to content

Commit 8aa08b1

Browse files
authored
Merge pull request #26 from Basavaraju-G/master
boskos libvirt cleanup changes
2 parents 02a179f + 53d45d4 commit 8aa08b1

File tree

5 files changed

+358
-0
lines changed

5 files changed

+358
-0
lines changed

boskos/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM gcr.io/k8s-staging-boskos/janitor
2+
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
3+
RUN apt-get --allow-releaseinfo-change update -y
4+
RUN apt-get install libvirt-clients libvirt-dev -y --fix-missing

boskos/prow_configs/boskos.yaml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: dynamicresourcelifecycles.boskos.k8s.io
5+
annotations:
6+
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/boskos/pull/105
7+
spec:
8+
group: boskos.k8s.io
9+
names:
10+
kind: DRLCObject
11+
listKind: DRLCObjectList
12+
plural: dynamicresourcelifecycles
13+
singular: dynamicresourcelifecycle
14+
scope: Namespaced
15+
versions:
16+
- name: v1
17+
served: true
18+
storage: true
19+
additionalPrinterColumns:
20+
- name: Type
21+
type: string
22+
description: The dynamic resource type.
23+
jsonPath: .spec.config.type
24+
- name: Min-Count
25+
type: integer
26+
description: The minimum count requested.
27+
jsonPath: .spec.min-count
28+
- name: Max-Count
29+
type: integer
30+
description: The maximum count requested.
31+
jsonPath: .spec.max-count
32+
schema:
33+
openAPIV3Schema:
34+
description: Defines the lifecycle of a dynamic resource. All
35+
Resource of a given type will be constructed using the same
36+
configuration
37+
type: object
38+
properties:
39+
spec:
40+
type: object
41+
properties:
42+
state:
43+
type: string
44+
max-count:
45+
description: Maxiumum number of resources expected. This
46+
maximum may be temporarily exceeded while resources are in
47+
the process of being deleted, though this is only expected
48+
when MaxCount is lowered.
49+
type: integer
50+
format: int32
51+
min-count:
52+
description: Minimum number of resources to be used as a
53+
buffer. Resources in the process of being deleted and
54+
cleaned up are included in this count.
55+
type: integer
56+
format: int32
57+
lifespan:
58+
description: Lifespan of a resource, time after which the
59+
resource should be reset
60+
type: integer
61+
format: int64
62+
config:
63+
description: Config information about how to create the
64+
object
65+
type: object
66+
properties:
67+
type:
68+
description: The dynamic resource type
69+
type: string
70+
content:
71+
type: string
72+
needs:
73+
description: Define the resource needs to create the object
74+
type: object
75+
x-kubernetes-preserve-unknown-fields: true
76+
---
77+
apiVersion: apiextensions.k8s.io/v1
78+
kind: CustomResourceDefinition
79+
metadata:
80+
name: resources.boskos.k8s.io
81+
annotations:
82+
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/boskos/pull/105
83+
spec:
84+
group: boskos.k8s.io
85+
names:
86+
kind: ResourceObject
87+
listKind: ResourceObjectList
88+
plural: resources
89+
singular: resource
90+
scope: Namespaced
91+
versions:
92+
- name: v1
93+
served: true
94+
storage: true
95+
additionalPrinterColumns:
96+
- name: Type
97+
type: string
98+
description: The resource type.
99+
jsonPath: .spec.type
100+
- name: State
101+
type: string
102+
description: The current state of the resource.
103+
jsonPath: .status.state
104+
- name: Owner
105+
type: string
106+
description: The current owner of the resource.
107+
jsonPath: .status.owner
108+
- name: Last-Updated
109+
type: date
110+
jsonPath: .status.lastUpdate
111+
schema:
112+
openAPIV3Schema:
113+
description: Abstracts any resource type that can be tracked by boskos
114+
type: object
115+
properties:
116+
spec:
117+
description: Holds information that are not likely to change
118+
type: object
119+
properties:
120+
type:
121+
type: string
122+
status:
123+
description: Holds information that are likely to change
124+
type: object
125+
properties:
126+
state:
127+
type: string
128+
owner:
129+
type: string
130+
lastUpdate:
131+
type: string
132+
format: date-time
133+
userData:
134+
type: object
135+
x-kubernetes-preserve-unknown-fields: true
136+
expirationDate:
137+
type: string
138+
format: date-time
139+
---
140+
kind: ClusterRole
141+
apiVersion: rbac.authorization.k8s.io/v1
142+
metadata:
143+
name: boskos
144+
rules:
145+
- apiGroups: ["boskos.k8s.io"]
146+
verbs: ["*"]
147+
resources: ["*"]
148+
---
149+
kind: ServiceAccount
150+
apiVersion: v1
151+
metadata:
152+
name: boskos
153+
namespace: test-pods
154+
---
155+
kind: ClusterRoleBinding
156+
apiVersion: rbac.authorization.k8s.io/v1
157+
metadata:
158+
name: boskos
159+
subjects:
160+
- kind: ServiceAccount
161+
name: boskos
162+
namespace: test-pods
163+
roleRef:
164+
kind: ClusterRole
165+
name: boskos
166+
apiGroup: rbac.authorization.k8s.io
167+
---
168+
apiVersion: apps/v1
169+
kind: Deployment
170+
metadata:
171+
name: boskos
172+
namespace: test-pods
173+
spec:
174+
replicas: 1 # one canonical source of resources
175+
selector:
176+
matchLabels:
177+
app: boskos
178+
template:
179+
metadata:
180+
labels:
181+
app: boskos
182+
namespace: test-pods
183+
spec:
184+
serviceAccountName: boskos
185+
terminationGracePeriodSeconds: 30
186+
containers:
187+
- name: boskos
188+
image: gcr.io/k8s-staging-boskos/boskos:v20211118-344faec
189+
args:
190+
- --config=/etc/config/boskos-resources.yaml
191+
- --namespace=test-pods
192+
ports:
193+
- containerPort: 8080
194+
protocol: TCP
195+
volumeMounts:
196+
- name: boskos-config
197+
mountPath: /etc/config
198+
readOnly: true
199+
volumes:
200+
- name: boskos-config
201+
configMap:
202+
name: resources
203+
---
204+
apiVersion: v1
205+
kind: Service
206+
metadata:
207+
name: boskos
208+
namespace: test-pods
209+
spec:
210+
selector:
211+
app: boskos
212+
ports:
213+
- name: default
214+
protocol: TCP
215+
port: 80
216+
targetPort: 8080
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: resources
5+
namespace: test-pods
6+
data:
7+
boskos-resources.yaml: |
8+
resources:
9+
- type: "libvirt-ppc64le-quota-slice"
10+
state: dirty
11+
names:
12+
- "libvirt-ppc64le-0-0"
13+
- "libvirt-ppc64le-0-1"
14+
- "libvirt-ppc64le-0-2"
15+
- "libvirt-ppc64le-0-3"
16+
- "libvirt-ppc64le-1-0"
17+
- "libvirt-ppc64le-1-1"
18+
- "libvirt-ppc64le-1-2"
19+
- "libvirt-ppc64le-2-0"
20+
- "libvirt-ppc64le-2-1"
21+
- "libvirt-ppc64le-2-2"
22+
- "libvirt-ppc64le-2-3"
23+
---
24+
kind: ConfigMap
25+
apiVersion: v1
26+
metadata:
27+
name: janitor-libvirt-ppc64le
28+
namespace: test-pods
29+
data:
30+
libvirt-ppc64le-janitor.sh: |-
31+
#!/bin/bash
32+
33+
set -o errexit
34+
set -o nounset
35+
set -o pipefail
36+
37+
ARCH=$(uname -m)
38+
39+
40+
LIBVIRT_VERSION=${LIBVIRT_VERSION:-"v1.0.1-alpha"}
41+
ARCH=$(uname -m)
42+
install_libvirtcli(){
43+
if ! command -h libvirtcli &> /dev/null; then
44+
echo "libvirtcli command not found, installing it."
45+
[ "${ARCH}" == "x86_64" ] && ARCH="amd64"
46+
# Installing binaries from github releases
47+
curl -fsL https://github.com/Basavaraju-G/janitor/releases/download/${LIBVIRT_VERSION}/libvirtcli-${ARCH} -o libvirtcli
48+
chmod +x ./libvirtcli
49+
mv ./libvirtcli /usr/bin
50+
fi
51+
}
52+
53+
54+
55+
main(){
56+
57+
args=$1
58+
case $1 in
59+
-l=*|--slice=*)
60+
leasedResource="${1#*=}"
61+
shift
62+
;;
63+
-*|--*)
64+
echo "Unknown option $1"
65+
exit 1
66+
;;
67+
*)
68+
;;
69+
esac
70+
install_libvirtcli
71+
# Deleting the libvirt resources
72+
libvirtcli -leasedResource "${leasedResource}"
73+
[ $? = 0 ] && echo "Succesfully deleted resources in ${leasedResource}"
74+
75+
}
76+
77+
main $@
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: boskos-janitor-nongke
5+
labels:
6+
app: boskos-janitor-nongke
7+
namespace: test-pods
8+
spec:
9+
replicas: 2
10+
selector:
11+
matchLabels:
12+
app: boskos-janitor-nongke
13+
template:
14+
metadata:
15+
labels:
16+
app: boskos-janitor-nongke
17+
spec:
18+
terminationGracePeriodSeconds: 300
19+
containers:
20+
- name: boskos-janitor-nongke
21+
image: quay.io/bgirriam/janitor:v20220208-21245b5
22+
args:
23+
- --boskos-url=http://boskos.test-pods.svc.cluster.local.
24+
- --resource-type=libvirt-ppc64le-quota-slice
25+
- --janitor-path=/root/libvirt-ppc64le-janitor.sh
26+
- --pool-size=20
27+
- --
28+
- --hours=0
29+
volumeMounts:
30+
- mountPath: "/root/libvirt-ppc64le-janitor.sh"
31+
name: janitor-libvirt-ppc64le
32+
subPath: "libvirt-ppc64le-janitor.sh"
33+
volumes:
34+
- name: janitor-libvirt-ppc64le
35+
configMap:
36+
name: janitor-libvirt-ppc64le
37+
defaultMode: 0755
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: boskos-reaper
5+
labels:
6+
app: boskos-reaper
7+
namespace: test-pods
8+
spec:
9+
selector:
10+
matchLabels:
11+
app: boskos-reaper
12+
replicas: 1 # one canonical source of resources
13+
template:
14+
metadata:
15+
labels:
16+
app: boskos-reaper
17+
spec:
18+
terminationGracePeriodSeconds: 30
19+
containers:
20+
- name: boskos-reaper
21+
image: gcr.io/k8s-staging-boskos/reaper:v20220208-21245b5
22+
args:
23+
- --boskos-url=http://boskos.test-pods.svc.cluster.local.
24+
- --resource-type=libvirt-ppc64le-quota-slice

0 commit comments

Comments
 (0)