skaffold
skaffold copied to clipboard
dev doesn't seem to tail logs or forward ports
truncated postgres logs
> kubectl logs postgres # ~
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
how I've been starting (killing with ctrl+c)
> skaffold dev # ppm -> 75-database ! ?
Listing files to watch...
Generating tags...
Checking cache...
Tags used in deployment:
Starting deploy...
- pod/postgres created
Waiting for deployments to stabilize...
Deployments stabilized in 25.357659ms
Press Ctrl+C to exit
Watching for changes...
^CCleaning up...
- pod "postgres" deleted
> skaffold diagnose # ppm -> 75-database ! ?
Skaffold version: ad9c4899cf485f6931cb9de2ac3419b83081f73d
Configuration version: skaffold/v2beta10
Number of artifacts: 0
Configuration
apiVersion: skaffold/v2beta10
kind: Config
metadata:
name: ppm
build:
tagPolicy:
gitCommit: {}
local:
concurrency: 1
deploy:
kubectl:
manifests:
- k8s/*.yaml
logs:
prefix: container
the actual pod
apiVersion: v1
kind: Pod
metadata:
name: postgres
spec:
containers:
- name: postgres
image: postgres:latest
ports:
- containerPort: 5432
name: postgres
env:
- name: POSTGRES_PASSWORD
value: UseSecrets
the port isn't forwarded
> telnet localhost 5432 # ppm -> 75-database ! ?
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
> skaffold version # ppm -> 75-database ! ? RC=1
v1.17.0
> docker --version # ppm -> 75-database ! ?
Docker version 19.03.13, build 4484c46d9d
> uname -a # ppm -> 75-database ! ?
Darwin Calebs-MBP 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64
didn't work setting these through skaffold run or setting the env vars either. this seems to work for port forwarding though
> kubectl port-forward postgres 5432:5432 # ppm -> 75-database ! ? RC=1
Forwarding from 127.0.0.1:5432 -> 5432
Forwarding from [::1]:5432 -> 5432
Handling connection for 5432
You have to specify --port-forward with skaffold dev
no logs
> skaffold dev --port-forward
Listing files to watch...
Generating tags...
Checking cache...
Tags used in deployment:
Starting deploy...
- pod/postgres created
Waiting for deployments to stabilize...
Deployments stabilized in 62.730253ms
Press Ctrl+C to exit
Watching for changes...
no forward
> telnet localhost 5432 # ppm -> 75-migrations — » ! + ? RC=1
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
It's an unfortunate limitation in Skaffold that it doesn't tail container logs for images it didn't build itself. To work around this you could try:
skaffold.yaml
apiVersion: skaffold/v2beta10
kind: Config
metadata:
name: ppm
build:
artifacts:
- image: postgres
tagPolicy:
gitCommit: {}
local:
concurrency: 1
deploy:
kubectl:
manifests:
- pod.yaml
logs:
prefix: container
Dockerfile
FROM postgres:latest
pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: postgres
spec:
containers:
- name: postgres
image: postgres
ports:
- containerPort: 5432
name: postgres
env:
- name: POSTGRES_PASSWORD
value: UseSecrets
Then we get the expected logs
❯ skaffold dev --port-forward --tail
Listing files to watch...
- postgres
Generating tags...
- postgres -> postgres:latest
Some taggers failed. Rerun with -vdebug for errors.
Checking cache...
- postgres: Not found. Building
Found [minikube] context, using local docker daemon.
Building [postgres]...
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM postgres:latest
---> f51c55ac75ed
Successfully built f51c55ac75ed
Successfully tagged postgres:latest
Tags used in deployment:
- postgres -> postgres:f51c55ac75ed8f2c2ba5fe44b7d065f3bdbc501fa7a798dc303aa293d2089a6c
Starting deploy...
- pod/postgres created
Waiting for deployments to stabilize...
Deployments stabilized in 22.08576ms
Press Ctrl+C to exit
Watching for changes...
[postgres] The files belonging to this database system will be owned by user "postgres".
[postgres] This user must also own the server process.
[postgres]
[postgres] The database cluster will be initialized with locale "en_US.utf8".
[postgres] The default database encoding has accordingly been set to "UTF8".
[postgres] The default text search configuration will be set to "english".
[postgres]
[postgres] Data page checksums are disabled.
[postgres]
[postgres] fixing permissions on existing directory /var/lib/postgresql/data ... ok
[postgres] creating subdirectories ... ok
[postgres] selecting dynamic shared memory implementation ... posix
[postgres] selecting default max_connections ... 100
[postgres] selecting default shared_buffers ... 128MB
[postgres] selecting default time zone ... Etc/UTC
[postgres] creating configuration files ... ok
[postgres] running bootstrap script ... ok
[postgres] performing post-bootstrap initialization ... ok
[postgres] syncing data to disk ... ok
[postgres]
[postgres]
[postgres] Success. You can now start the database server using:
[postgres]
[postgres] pg_ctl -D /var/lib/postgresql/data -l logfile start
[postgres]
[postgres] initdb: warning: enabling "trust" authentication for local connections
[postgres] You can change this by editing pg_hba.conf or using the option -A, or
[postgres] --auth-local and --auth-host, the next time you run initdb.
[postgres] waiting for server to start....2020-12-02 07:30:15.474 UTC [46] LOG: starting PostgreSQL 13.1 (Debian 13.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
[postgres] 2020-12-02 07:30:15.476 UTC [46] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
[postgres] 2020-12-02 07:30:15.482 UTC [47] LOG: database system was shut down at 2020-12-02 07:30:15 UTC
[postgres] 2020-12-02 07:30:15.485 UTC [46] LOG: database system is ready to accept connections
[postgres] done
[postgres] server started
[postgres]
[postgres] /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
[postgres]
[postgres] 2020-12-02 07:30:15.560 UTC [46] LOG: received fast shutdown request
[postgres] waiting for server to shut down....2020-12-02 07:30:15.562 UTC [46] LOG: aborting any active transactions
[postgres] 2020-12-02 07:30:15.566 UTC [46] LOG: background worker "logical replication launcher" (PID 53) exited with exit code 1
[postgres] 2020-12-02 07:30:15.566 UTC [48] LOG: shutting down
[postgres] 2020-12-02 07:30:15.579 UTC [46] LOG: database system is shut down
[postgres] done
[postgres] server stopped
[postgres]
[postgres] PostgreSQL init process complete; ready for start up.
[postgres]
[postgres] 2020-12-02 07:30:15.685 UTC [1] LOG: starting PostgreSQL 13.1 (Debian 13.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
[postgres] 2020-12-02 07:30:15.685 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
[postgres] 2020-12-02 07:30:15.685 UTC [1] LOG: listening on IPv6 address "::", port 5432
[postgres] 2020-12-02 07:30:15.687 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
[postgres] 2020-12-02 07:30:15.692 UTC [55] LOG: database system was shut down at 2020-12-02 07:30:15 UTC
[postgres] 2020-12-02 07:30:15.697 UTC [1] LOG: database system is ready to accept connections
that should obviously change, but even though that might fix the problem...
that doesn't change that skaffold dev --port-forward does NOT forward the port
I missed that part of the question. Since logging and port forwarding use the same pod selector they both face this issue.
that's fun... This wasn't really a question, it was obvious that things weren't working as the documentation said they should. I'd say the documentation needs updating to reflect this and ultimately this really should be fixed for both.
As it stands this project isn't particularly useful to me sadly, as I don't run containers this way in development, and I haven't found that the CI systems I use support kubernetes but they do support docker-compose so I'd have to use it anyways.
Hi @gsquared94 , I'm having a similar problem tailing logs from containers whose images weren't built by Skaffold. Specifically, in my situation, I'm pulling an image from a private docker registry which gets pulled down using imagePullSecrets, which builds and starts the pod successfully. But when running skaffold dev --port-forward, I don't see any logs from that pulled image.
Its only when I tried your suggestion and built the image locally, from the actual repo and refer it directly from the Dockerfile, is when I saw some logs. I have other Skaffolds also suffering the same problem with no logs. Please update the documentation with these bits, as it was quite hard to track down this fix.
Is there a ticket for this logging problem for non-skaffold-built images? I noticed the port-forwarding feature-request, was hoping for a similar one for logging, or is that going to get fixed for both?
Thanks!
@shuvozula I think we would try to fix this issue for both port forwarding and logging if we got to it. However, we're currently not heavily prioritizing this issue within our team. PRs always welcome!
I'm just curious if 4 years later this was ever fixed/improved