-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from gianlucam76/shard-manifest
Autogenerate YAML for deployment for cluster sharding
- Loading branch information
Showing
5 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
control-plane: sc-manager | ||
name: sc-manager-{{.SHARD}} | ||
namespace: projectsveltos | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
control-plane: sc-manager | ||
template: | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/default-container: manager | ||
labels: | ||
control-plane: sc-manager | ||
spec: | ||
containers: | ||
- args: | ||
- --health-probe-bind-address=:8081 | ||
- --metrics-bind-address=127.0.0.1:8080 | ||
- --shard-key={{.SHARD}} | ||
- --v=5 | ||
command: | ||
- /manager | ||
image: projectsveltos/sveltoscluster-manager-amd64:dev | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8081 | ||
initialDelaySeconds: 15 | ||
periodSeconds: 20 | ||
name: manager | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: 8081 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 128Mi | ||
requests: | ||
cpu: 10m | ||
memory: 64Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
- args: | ||
- --secure-listen-address=0.0.0.0:8443 | ||
- --upstream=http://127.0.0.1:8080/ | ||
- --logtostderr=true | ||
- --v=0 | ||
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.12.0 | ||
name: kube-rbac-proxy | ||
ports: | ||
- containerPort: 8443 | ||
name: https | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 128Mi | ||
requests: | ||
cpu: 5m | ||
memory: 64Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
securityContext: | ||
runAsNonRoot: true | ||
serviceAccountName: sc-manager | ||
terminationGracePeriodSeconds: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Define the YAML file path | ||
yaml_file=$1 | ||
output_file=$2 | ||
|
||
# Create a temporary directory to store the split sections | ||
mkdir -p temp_yaml_sections | ||
|
||
# Initialize variables for section counting and flag to track changes | ||
section_count=0 | ||
in_section=false | ||
|
||
# Iterate through the YAML file | ||
while IFS= read -r line; do | ||
if [[ $line == '---' ]]; then | ||
# Start a new section | ||
in_section=true | ||
section_count=$((section_count + 1)) | ||
current_section_file="temp_yaml_sections/section_${section_count}.yaml" | ||
continue | ||
fi | ||
|
||
if [[ $in_section == true ]]; then | ||
# Replace "shard-key=" to contain shard info | ||
if [[ $line == *"shard-key"* ]]; then | ||
line=$(echo "$line" | sed "s/shard-key=/shard-key={{.SHARD}}/") | ||
fi | ||
|
||
# Replace "name" to contain shard info | ||
if [[ $line == *"name: sc-manager"* ]]; then | ||
line=$(echo "$line" | sed "s/sc-manager/sc-manager-{{.SHARD}}/") | ||
fi | ||
|
||
# Write the line to the current section file | ||
echo "$line" >> "$current_section_file" | ||
fi | ||
done < "$yaml_file" | ||
|
||
# Iterate through the split sections and print those with "kind: Deployment" | ||
for section_file in temp_yaml_sections/*.yaml; do | ||
if grep -q "kind: Deployment" "$section_file"; then | ||
cat "$section_file" > $output_file | ||
fi | ||
done | ||
|
||
# Remove the temporary directory | ||
rm -r temp_yaml_sections |