Skip to content

Commit

Permalink
docs: Add more userdata examples for node log query (#4617)
Browse files Browse the repository at this point in the history
  • Loading branch information
rothgar committed Sep 13, 2023
1 parent 5b384e5 commit 2498587
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
45 changes: 45 additions & 0 deletions examples/provisioner/launchtemplates/al2-kubelet-log-query.yaml
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 examples/provisioner/launchtemplates/ubuntu-kubelet-log-query.yaml
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--

0 comments on commit 2498587

Please sign in to comment.