Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #140 from poblin-orange/develop
Browse files Browse the repository at this point in the history
124.11 - fix prefixed agents node drain/cordon lifecycle
  • Loading branch information
poblin-orange authored Sep 3, 2023
2 parents 1d1a621 + 5dadbd9 commit fd9f7f4
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .final_builds/jobs/k3s-agent/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ builds:
version: fbbeeb447edbce478b6101ab2d6e4c7332e0588035cefe649ad9dbcc0ea707be
blobstore_id: 470f5946-41a9-4586-6482-3492a7041453
sha1: sha256:439ac2a7a5efa3c19ae77978f2fa8e863815081ad46fdfbdf3998fc3032da121
fc6f198fd91f9f5abdfd32e9515026921ec96f1fc9957d3b8c862c91ce1e02e0:
version: fc6f198fd91f9f5abdfd32e9515026921ec96f1fc9957d3b8c862c91ce1e02e0
blobstore_id: cadb1757-67e5-4d37-7013-a77d72256f0b
sha1: sha256:6663e2a7f42a1875521c501ae4ab1b70afe4014815ae7e96d5b1e84907742a1e
format-version: "2"
4 changes: 4 additions & 0 deletions .final_builds/jobs/k3s-server/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,8 @@ builds:
version: e2d4607b2ca54abbad5540e320dcb6b419260b3991b3b7d4906dbd8fe5210b2f
blobstore_id: a0d4c35d-9470-41b6-6d8d-d0764f01904a
sha1: sha256:7ed71d98c9b295204ff4b1efba0448456cc45ae714212db6f69e3f6b9dc558c2
f9169af1999c76bfa76c57eab2f3eda0da5fec0205e6ae85d5104309f33a3c55:
version: f9169af1999c76bfa76c57eab2f3eda0da5fec0205e6ae85d5104309f33a3c55
blobstore_id: 276b6c37-a547-47f7-6761-8d04c4e4480f
sha1: sha256:df6a1254efab8b3e13b0db04c01ce5a535823abfcdc70393acdafa00589f40fa
format-version: "2"
10 changes: 7 additions & 3 deletions jobs/k3s-agent/templates/bin/drain.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@

export JOB_DIR=/var/vcap/sys/log/k3s-agent

export K3S_NODE_NAME=<%= spec.name %>-<%= spec.index %>
<% if_p('k3s.node_name_prefix') do |prefix| %>
export K3S_NODE_NAME=<%= prefix %>-<%= spec.index %>
<% end %>

<% if_p('k3s.drain.kubeconfig') do |kubeconfig| %>
#create local kubeconfig
cat - > /var/vcap/data/k3s-agent/drain-kubeconfig.yaml <<EOF
<%= kubeconfig %>
EOF

#cordon
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/data/k3s-agent/drain-kubeconfig.yaml cordon <%= spec.name %>-<%= spec.index %> \
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/data/k3s-agent/drain-kubeconfig.yaml cordon $K3S_NODE_NAME \
>> $JOB_DIR/drain.log \
2>> $JOB_DIR/drain-stderr.log


#drain
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/data/k3s-agent/drain-kubeconfig.yaml drain <%= spec.name %>-<%= spec.index %> \
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/data/k3s-agent/drain-kubeconfig.yaml drain $K3S_NODE_NAME \
--delete-emptydir-data=<%= p('k3s.drain.delete-emptydir-data') %> \
--disable-eviction=<%= p('k3s.drain.disable-eviction') %> \
--grace-period=<%= p('k3s.drain.grace-period') %> \
Expand Down
9 changes: 8 additions & 1 deletion jobs/k3s-agent/templates/bin/post-start.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ else
echo "kubelet is down, post-start failure"
fi

export K3S_NODE_NAME=<%= spec.name %>-<%= spec.index %>
<% if_p('k3s.node_name_prefix') do |prefix| %>
export K3S_NODE_NAME=<%= prefix %>-<%= spec.index %>
<% end %>


#uncordon if agent drain set
<% if_p('k3s.drain.kubeconfig') do |kubeconfig| %>
#create local kubeconfig
cat - > /var/vcap/data/k3s-agent/drain-kubeconfig.yaml <<EOF
<%= kubeconfig %>
EOF


#uncordon
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/data/k3s-agent/drain-kubeconfig.yaml uncordon <%= spec.name %>-<%= spec.index %> \
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/data/k3s-agent/drain-kubeconfig.yaml uncordon $K3S_NODE_NAME \
>> $JOB_DIR/post-start.log \
2>> $JOB_DIR/post-start-stderr.log

Expand Down
7 changes: 6 additions & 1 deletion jobs/k3s-server/templates/bin/drain.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

export JOB_DIR=/var/vcap/sys/log/k3s-server

export K3S_NODE_NAME=<%= spec.name %>-<%= spec.index %>
<% if_p('k3s.node_name_prefix') do |prefix| %>
export K3S_NODE_NAME=<%= prefix %>-<%= spec.index %>
<% end %>

#/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/store/k3s-server/kubeconfig.yml get pods --all-namespaces

#drain
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/store/k3s-server/kubeconfig.yml drain <%= spec.name %>-<%= spec.index %> \
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/store/k3s-server/kubeconfig.yml drain $K3S_NODE_NAME \
--delete-emptydir-data=<%= p('k3s.drain.delete-emptydir-data') %> \
--disable-eviction=<%= p('k3s.drain.disable-eviction') %> \
--grace-period=<%= p('k3s.drain.grace-period') %> \
Expand Down
7 changes: 6 additions & 1 deletion jobs/k3s-server/templates/bin/post-start.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

export K3S_NODE_NAME=<%= spec.name %>-<%= spec.index %>
<% if_p('k3s.node_name_prefix') do |prefix| %>
export K3S_NODE_NAME=<%= prefix %>-<%= spec.index %>
<% end %>

#prepare kubeconfig for remote access
cat /var/vcap/store/k3s-server/k3s.yaml |sed -r 's/(\b[0-9]{1,3}\.){3}[0-9]{1,3}\b'/"<%= spec.ip %>"/ > /var/vcap/store/k3s-server/kubeconfig.yml

Expand All @@ -13,7 +18,7 @@ cat /var/vcap/store/k3s-server/k3s.yaml |sed -r 's/(\b[0-9]{1,3}\.){3}[0-9]{1,3}
timeout 300 sh -c 'until nc -z <%= vip %> 6443; do sleep 1; done' /var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/store/k3s-server/kubeconfig.yml get pods --all-namespaces
<% end %>
#uncordon
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/store/k3s-server/kubeconfig.yml uncordon <%= spec.name %>-<%= spec.index %>
/var/vcap/packages/kubectl-k3s/kubectl --kubeconfig=/var/vcap/store/k3s-server/kubeconfig.yml uncordon $K3S_NODE_NAME


#tempo to wait for kubelet to schedule pods before finishing instance group update
Expand Down
2 changes: 2 additions & 0 deletions releases/k3s/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ builds:
version: "20"
69e76586-6f75-423f-6a92-a13775aab2bb:
version: "5"
6bc23bc7-9bc8-41b5-5006-8932d5828ff8:
version: "124.11"
70ae22e2-9a7e-4826-630c-a49f617ad223:
version: "6"
7c26a634-ba01-472b-5ab4-64db150cae72:
Expand Down
65 changes: 65 additions & 0 deletions releases/k3s/k3s-124.11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: k3s
version: "124.11"
commit_hash: 820e379
uncommitted_changes: false
jobs:
- name: k3s-agent
version: fc6f198fd91f9f5abdfd32e9515026921ec96f1fc9957d3b8c862c91ce1e02e0
fingerprint: fc6f198fd91f9f5abdfd32e9515026921ec96f1fc9957d3b8c862c91ce1e02e0
sha1: sha256:6663e2a7f42a1875521c501ae4ab1b70afe4014815ae7e96d5b1e84907742a1e
packages:
- k3s
- kubectl-k3s
- k3s-images
- nerdctl
- name: k3s-agent-airgaped-images
version: dac8160deeef67d642c67065cdb584c53ca84807717f4b7abb3e748badb97313
fingerprint: dac8160deeef67d642c67065cdb584c53ca84807717f4b7abb3e748badb97313
sha1: sha256:56989c04162b348ce691ad78d9ceaefc4b46338df95ebe87fda1e5ce0a30d429
packages:
- k3s-images
- name: k3s-server
version: f9169af1999c76bfa76c57eab2f3eda0da5fec0205e6ae85d5104309f33a3c55
fingerprint: f9169af1999c76bfa76c57eab2f3eda0da5fec0205e6ae85d5104309f33a3c55
sha1: sha256:df6a1254efab8b3e13b0db04c01ce5a535823abfcdc70393acdafa00589f40fa
packages:
- k3s
- k9s
- kubectl-k3s
- nerdctl
- name: k3s-server-airgaped-images
version: 3e8cc00744f582f54235a554c9a5a1bcbc16c8848330d8b17fbe1ab270f7d2ef
fingerprint: 3e8cc00744f582f54235a554c9a5a1bcbc16c8848330d8b17fbe1ab270f7d2ef
sha1: sha256:fbae88a6d6e06d8ac29288b73a971832e77d2483978c56481844e1c7f8e77c78
packages:
- k3s-images
packages:
- name: k3s
version: 2a86c5528d71de652d868e69fc9f017d25f67515faef5280ed69dfb37db64498
fingerprint: 2a86c5528d71de652d868e69fc9f017d25f67515faef5280ed69dfb37db64498
sha1: sha256:7b4efc0354fd92befc3ad7cff1a4d15ed78e9801e0e149b6d95bfe3ac35251cb
dependencies: []
- name: k3s-images
version: e758dece4a82c66f1f1c0b9f9b3991ff2fe639510be32869b12cdf52baad484c
fingerprint: e758dece4a82c66f1f1c0b9f9b3991ff2fe639510be32869b12cdf52baad484c
sha1: sha256:69475239e32a6ee4bcd036fa2b066548111dac6e2031c3b2e03e1f858a73534b
dependencies: []
- name: k9s
version: 5950fdb3fe5cf31d54de992dd8dfdb17bc43eca03901b375c7e54ed89203966b
fingerprint: 5950fdb3fe5cf31d54de992dd8dfdb17bc43eca03901b375c7e54ed89203966b
sha1: sha256:d0ad55e5c5f85d986c15346247d9dec6f5b2712a5a81ebb8af80c9b5676c23a4
dependencies: []
- name: kubectl-k3s
version: 7ad3a6f1733dd6068d1f380ffff2daeaec2d7bbefdc297873854c55eec287f86
fingerprint: 7ad3a6f1733dd6068d1f380ffff2daeaec2d7bbefdc297873854c55eec287f86
sha1: sha256:0325c1d22e341d13c91abf7df05c31c3df8effa6da3c3d0bca3920e26edca721
dependencies: []
- name: nerdctl
version: 3ef7aaf0a97b5ea75f13913f2c73609b90e9fb46695d743c2acedd5d0d9e4eb4
fingerprint: 3ef7aaf0a97b5ea75f13913f2c73609b90e9fb46695d743c2acedd5d0d9e4eb4
sha1: sha256:beb08f27a3f548472c8c0edee96e813fba538d7e4b2229325e5262cc30aa7d30
dependencies: []
license:
version: cf0ca1fe65dee9607c7bb9460a3f20835e582cbb7f5b2c3625fba2e21d7e91b9
fingerprint: cf0ca1fe65dee9607c7bb9460a3f20835e582cbb7f5b2c3625fba2e21d7e91b9
sha1: sha256:cbe3175489dfaec91e9f392399fbfb68e008885feb91a3b8d493a35d2fc5a8fa

0 comments on commit fd9f7f4

Please sign in to comment.