Skip to content

Commit ce266ae

Browse files
janetkuok8s-ci-robot
authored andcommitted
Add script for generating release manifests
1 parent a563b31 commit ce266ae

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ test-e2e:
3232
.PHONY: lint-go
3333
lint-go:
3434
./dev/tools/lint-go
35+
36+
# Example usage: make release TAG=v0.1.0
37+
.PHONY: release
38+
release:
39+
go mod tidy
40+
go generate ./...
41+
./dev/tools/release --tag=${TAG}

dev/tools/release

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2025 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
import os
17+
import glob
18+
import re
19+
import argparse
20+
21+
def main():
22+
parser = argparse.ArgumentParser(description='Generate release manifests.')
23+
parser.add_argument('--tag', required=True, help='The git tag for the release.')
24+
args = parser.parse_args()
25+
26+
# Create the release_assets directory if it doesn't exist
27+
if not os.path.exists('release_assets'):
28+
os.makedirs('release_assets')
29+
30+
all_yaml_files = glob.glob('k8s/**/*.yaml', recursive=True)
31+
image_url = f'registry.k8s.io/agent-sandbox/agent-sandbox-controller:{args.tag}'
32+
33+
# --- Generate manifest.yaml ---
34+
print('INFO: Preparing core manifest.yaml')
35+
manifest_files = [f for f in all_yaml_files if 'extensions' not in os.path.basename(f)]
36+
with open('release_assets/manifest.yaml', 'w') as outfile:
37+
for fname in sorted(manifest_files):
38+
with open(fname) as infile:
39+
outfile.write(infile.read())
40+
outfile.write('---\n')
41+
42+
43+
# Replace image placeholder in manifest.yaml
44+
print(f'INFO: Replacing image placeholder in core manifest.yaml with: {image_url}')
45+
with open('release_assets/manifest.yaml', 'r') as file:
46+
filedata = file.read()
47+
48+
filedata = re.sub(r'ko://sigs.k8s.io/agent-sandbox/cmd/agent-sandbox-controller.*', image_url, filedata)
49+
50+
with open('release_assets/manifest.yaml', 'w') as file:
51+
file.write(filedata)
52+
print('INFO: Successfully created release_assets/manifest.yaml')
53+
54+
# --- Generate extensions.yaml ---
55+
print('INFO: Preparing extensions.yaml')
56+
extension_files = [f for f in all_yaml_files if 'extensions' in os.path.basename(f)]
57+
with open('release_assets/extensions.yaml', 'w') as outfile:
58+
for fname in sorted(extension_files):
59+
with open(fname) as infile:
60+
outfile.write(infile.read())
61+
outfile.write('---\n')
62+
63+
# Replace image placeholder in extensions.yaml
64+
print(f'INFO: Replacing image placeholder in extensions.yaml with: {image_url}')
65+
with open('release_assets/extensions.yaml', 'r') as file:
66+
filedata = file.read()
67+
68+
filedata = re.sub(r'ko://sigs.k8s.io/agent-sandbox/cmd/agent-sandbox-controller.*', image_url, filedata)
69+
70+
with open('release_assets/extensions.yaml', 'w') as file:
71+
file.write(filedata)
72+
print('INFO: Successfully created release_assets/extensions.yaml')
73+
74+
75+
if __name__ == '__main__':
76+
main()

k8s/deployment.yaml renamed to k8s/controller.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
kind: Namespace
23
apiVersion: v1
34
metadata:

k8s/extensions.controller.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
kind: StatefulSet
3+
apiVersion: apps/v1
4+
metadata:
5+
name: agent-sandbox-controller
6+
namespace: agent-sandbox-system
7+
labels:
8+
app: agent-sandbox-controller
9+
spec:
10+
serviceName: agent-sandbox-controller
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
app: agent-sandbox-controller
15+
template:
16+
metadata:
17+
labels:
18+
app: agent-sandbox-controller
19+
spec:
20+
serviceAccountName: agent-sandbox-controller
21+
containers:
22+
- name: agent-sandbox-controller
23+
image: ko://sigs.k8s.io/agent-sandbox/cmd/agent-sandbox-controller # placeholder value, replaced by deployment scripts
24+
args:
25+
- "--extensions"

0 commit comments

Comments
 (0)