Open alehanderoo opened 5 months ago
Got it working already! Posting it here for anyone having the same issue.
run kubectl edit svc cluster-monitoring-grafana -n default
on control_plane node.
This will show the following vi editor.
Change the type to NodePort
and add the nodePort port
.
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Service
metadata:
annotations:
meta.helm.sh/release-name: cluster-monitoring
meta.helm.sh/release-namespace: default
creationTimestamp: "2024-06-04T15:41:14Z"
labels:
app.kubernetes.io/instance: cluster-monitoring
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: grafana
app.kubernetes.io/version: 10.4.1
helm.sh/chart: grafana-7.3.11
name: cluster-monitoring-grafana
namespace: default
resourceVersion: "14694"
uid: 2b047274-31cf-413b-8dc2-14b8571a8330
spec:
clusterIP: 10.43.27.129
clusterIPs:
- 10.43.27.129
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: http-web
nodePort: 30080 # Optional: specify a port, or leave it to let Kubernetes assign one
port: 80
protocol: TCP
targetPort: 3000
selector:
app.kubernetes.io/instance: cluster-monitoring
app.kubernetes.io/name: grafana
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
run kubectl get svc cluster-monitoring-grafana -n default
to validate the settings.
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cluster-monitoring-grafana NodePort 10.43.27.129 <none> 80:30080/TCP 4h27m
Does not seem to work after a reboot.
It is probably because it is handeld by helm. I have the same issue and I am trying to convice helm to do it
UPDATE:
Ok, it wasn't that hard after all. You can either extend this file on tasks[1].values
with:
grafana:
service:
type: NodePort
nodePort:30080
and uninstall with helm and reinstall it with ansible. Or you can just uninstall it with helm and put all the values into file like values.yml
:
alertmanager:
enabled: false
grafana:
service:
type: NodePort
nodePort: 30080
And then install it again with helm:
helm install prometheus-stack prometheus-community/kube-prometheus-stack -f values.yaml --kubeconfig /etc/rancher/k3s/k3s.yaml
It then creates Grafana service with type NodePort accessible from specified port
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 40h
prometheus-operated ClusterIP None <none> 9090/TCP 13m
prometheus-stack-grafana NodePort 10.43.10.202 <none> 80:30080/TCP 13m
prometheus-stack-kube-prom-operator ClusterIP 10.43.89.109 <none> 443/TCP 13m
prometheus-stack-kube-prom-prometheus ClusterIP 10.43.61.6 <none> 9090/TCP,8080/TCP 13m
prometheus-stack-kube-state-metrics ClusterIP 10.43.165.23 <none> 8080/TCP 13m
prometheus-stack-prometheus-node-exporter ClusterIP 10.43.155.255 <none> 9100/TCP 13m
Btw @alehanderoo, kubectl port-forward
is temporary thing and it should wait for termination from user - it creates temporary forward rule and waits until you are finish (ctrl+c
). That is why it looks like it hangs
Hi @geerlingguy,
First of all, thank you for open-sourcing this! I’ve learned a lot about Ansible and server configuration over the last few days (and nights)! What a fantastic tool!
Describe the bug
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
nano ~/.kube/config
I changed the127.0.0.1
to192.168.2.52
(my wlan0 of the control_plane on which drupal is accessible from my workstation)When I then run
kubectl port-forward service/cluster-monitoring-grafana :80
(as user and as root) the device does not finish the command and grafana is never accessible.Opening
http://192.168.2.52:46238/
does not return a page.Troubleshooting
I'm running a self-built cluster. Control_plane on a rockpi4:
Remaining 4 nodes: (Rpi4 and Rpi3)
Networking:
I needed to update the networking.yml so my nodes got internet through wlan0 of the rockpi -> this works
my configure_routing.yml file for reference (I run this playbook prior to running main.yml):
name: Set up static networking configuration. hosts: cluster gather_facts: false become: true vars_files:
name: Configure Control Plane (Node1) hosts: control_plane become: true
handlers:
name: restart dnsmasq ansible.builtin.service: name: dnsmasq state: restarted
name: persist iptables rules ansible.builtin.command: netfilter-persistent save
tasks:
name: Install routing prerequisites. ansible.builtin.apt: name:
name: Ensure netfilter-persistent is enabled. ansible.builtin.service: name: netfilter-persistent enabled: true
name: Ensure dnsmasq is running and enabled. ansible.builtin.service: name: dnsmasq state: started enabled: true
name: Enable IPv4 forwarding. ansible.posix.sysctl: name: net.ipv4.ip_forward value: '1' sysctl_set: yes
name: Remove default route via eth0 command: ip route del default via 192.168.3.254 dev eth0 ignore_errors: yes
name: Add default route via wlan0 with correct metric command: ip route add default via 192.168.2.254 dev wlan0 metric 100 ignore_errors: yes
name: Flush existing NAT rules command: iptables -t nat -F
name: Flush existing NAT rules command: sudo iptables -F FORWARD
name: Set up NAT for wlan0 ansible.builtin.iptables: table: nat chain: POSTROUTING jump: MASQUERADE out_interface: wlan0 source: 192.168.3.0/24 notify: persist iptables rules
name: Ensure FORWARD chain allows traffic between interfaces ansible.builtin.iptables: table: filter chain: FORWARD jump: ACCEPT in_interface: eth0 out_interface: wlan0 source: 192.168.3.0/24 ctstate: NEW,ESTABLISHED,RELATED notify: persist iptables rules
name: Ensure FORWARD chain allows returning traffic ansible.builtin.iptables: table: filter chain: FORWARD jump: ACCEPT in_interface: wlan0 out_interface: eth0 ctstate: ESTABLISHED,RELATED notify: persist iptables rules
name: Configure dnsmasq for bridged DNS. ansible.builtin.copy: dest: /etc/dnsmasq.d/bridge.conf content: | interface=eth0 bind-interfaces server=1.1.1.1 server=1.0.0.1 domain-needed bogus-priv notify: restart dnsmasq
See: https://github.com/geerlingguy/turing-pi-2-cluster/issues/9
name: Configure Nodes hosts: nodes become: true tasks:
name: Remove the incorrect default gateway command: ip route del default via 192.168.3.254 dev eth0 ignore_errors: yes
name: Set the correct default gateway command: ip route add default via 192.168.3.69 ignore_errors: yes
name: Ensure DNS configuration lineinfile: path: /etc/resolv.conf line: 'nameserver 8.8.8.8' create: yes state: present
name: Ping google.com to check connectivity ansible.builtin.shell: | ping -c 4 google.com | grep 'time=' || echo "Ping failed" register: ping_test_result changed_when: false failed_when: ping_test_result.rc != 0 or not 'ms' in ping_test_result.stdout
name: Display ping test result debug: msg: "{{ ping_test_result.stdout }}"
Main installation: