TheK8sBook
TheK8sBook copied to clipboard
Chapter 5 app connection refused
In the chapter on namespaces I'm running into problems getting the-bus app to accept a curl request. Everything seems to match the output from the examples in the book with the exception of the ServiceAccounts last-applied-configuration warning when applying shield-app.yml. If I go into the pod and install curl I get a response when hitting localhost. Any idea what I'm doing wrong or how I can troubleshoot?
kubectl version Client: v1.21 Server: v1.21
k3d version k3d version v4.4.7 k3s version v1.21.2-k3s1 (default)
kubectl apply -f shield-app.yml
Warning: resource serviceaccounts/default is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
serviceaccount/default configured
service/the-bus created
pod/triskelion created
kubectl get pods -n shield
NAME READY STATUS RESTARTS AGE
triskelion 1/1 Running 0 117s
kubectl get svc -n shield
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
the-bus NodePort 10.43.196.219 <none> 8080:31112/TCP 2m51s
kubectl describe svc -n shield
Name: the-bus
Namespace: shield
Labels: <none>
Annotations: <none>
Selector: env=marvel
Type: NodePort
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.196.219
IPs: 10.43.196.219
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
NodePort: <unset> 31112/TCP
Endpoints: 10.42.1.3:8080
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
curl localhost:31112
curl: (7) Failed to connect to localhost port 31112: Connection refused
kubectl exec -it triskelion -n shield -- sh
/usr/src/app # curl localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>AOS</title>
<link rel="stylesheet" type="text/css" href="/css/main.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:300" >
</head>
<body>
<div class="main">
<img src="/images/image.png"/>
<div class="content">
<div id="message">
Agents of S.H.I.E.L.D
</div>
<div id="info">
<table>
<tr>
<th>Pod/container/host that serviced this request:</th>
<td>triskelion</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>