-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add more userdata examples for node log query (#4617)
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
examples/provisioner/launchtemplates/al2-kubelet-log-query.yaml
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,45 @@ | ||
# This example provisioner will provision instances using the AL2 EKS-Optimized AMI | ||
# and will be prepended to a Karpenter managed section that will bootstrap the kubelet. | ||
|
||
apiVersion: karpenter.sh/v1alpha5 | ||
kind: Provisioner | ||
metadata: | ||
name: default | ||
spec: | ||
providerRef: | ||
name: al2 | ||
--- | ||
apiVersion: karpenter.k8s.aws/v1alpha1 | ||
kind: AWSNodeTemplate | ||
metadata: | ||
name: al2 | ||
spec: | ||
amiFamily: AL2 | ||
subnetSelector: | ||
karpenter.sh/discovery: my-cluster | ||
securityGroupSelector: | ||
karpenter.sh/discovery: my-cluster | ||
userData: | | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/mixed; boundary="BOUNDARY" | ||
--BOUNDARY | ||
Content-Type: text/x-shellscript; charset="us-ascii" | ||
#!/bin/bash | ||
set -e | ||
# Add additional KUBELET_EXTRA_ARGS to the service | ||
# Requires Kubernetes 1.27 (alpha feature) | ||
cat << EOF > /etc/systemd/system/kubelet.service.d/90-kubelet-extra-args.conf | ||
[Service] | ||
Environment="KUBELET_EXTRA_ARGS=--feature-gates=NodeLogQuery=true $KUBELET_EXTRA_ARGS" | ||
EOF | ||
systemctl daemon-reload | ||
# Enable log handler and log query to the kubelet configuration | ||
echo "$(jq '.enableSystemLogHandler=true' /etc/kubernetes/kubelet/kubelet-config.json)" > /etc/kubernetes/kubelet/kubelet-config.json | ||
echo "$(jq '.enableSystemLogQuery=true' /etc/kubernetes/kubelet/kubelet-config.json)" > /etc/kubernetes/kubelet/kubelet-config.json | ||
--BOUNDARY-- |
44 changes: 44 additions & 0 deletions
44
examples/provisioner/launchtemplates/ubuntu-kubelet-log-query.yaml
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,44 @@ | ||
# This example provisioner will provision instances using the Ubuntu EKS AMI | ||
# and will be prepended to a Karpenter managed section that will bootstrap the kubelet. | ||
|
||
apiVersion: karpenter.sh/v1alpha5 | ||
kind: Provisioner | ||
metadata: | ||
name: default | ||
spec: | ||
providerRef: | ||
name: ubuntu | ||
--- | ||
apiVersion: karpenter.k8s.aws/v1alpha1 | ||
kind: AWSNodeTemplate | ||
metadata: | ||
name: ubuntu | ||
spec: | ||
amiFamily: Ubuntu | ||
subnetSelector: | ||
karpenter.sh/discovery: my-cluster | ||
securityGroupSelector: | ||
karpenter.sh/discovery: my-cluster | ||
userData: | | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/mixed; boundary="BOUNDARY" | ||
--BOUNDARY | ||
Content-Type: text/x-shellscript; charset="us-ascii" | ||
#!/bin/bash | ||
# There is currently a bug with log query and kubelet running inside a snap environment | ||
# https://github.com/kubernetes/kubernetes/issues/120618 | ||
# This example is provided for reference on how to change Ubuntu settings in user data | ||
set -e | ||
# This requires Kubernetes 1.27 or above (alpha feature) | ||
# This modifies the configuration of the /etc/eks/bootstrap.sh script because /etc/kubernetes/kubelet/kubelet-config.json | ||
# doesn't exist before bootstrap.sh is run | ||
sed -i 's/args="$KUBELET_EXTRA_ARGS"/args="--feature-gates=NodeLogQuery=true $KUBELET_EXTRA_ARGS"/g' /etc/eks/bootstrap.sh | ||
sed -i '/# writes kubeReserved and evictionHard/a echo "$(jq .enableSystemLogHandler=true $KUBELET_CONFIG)" > $KUBELET_CONFIG' /etc/eks/bootstrap.sh | ||
sed -i '/# writes kubeReserved and evictionHard/a echo "$(jq .enableSystemLogQuery=true $KUBELET_CONFIG)" > $KUBELET_CONFIG' /etc/eks/bootstrap.sh | ||
--BOUNDARY-- |