crc-org / crc

CRC is a tool to help you run containers. It manages a local OpenShift 4.x cluster, Microshift or a Podman VM optimized for testing and development purposes
https://crc.dev
Apache License 2.0
1.26k stars 242 forks source link

Release ports on `crc stop` #4217

Closed vyasgun closed 5 months ago

vyasgun commented 5 months ago

crc start opens and uses ports which do not need to remain exposed after the machine has been stopped. This PR will ensure that the ports are unexposed on crc stop

Fixes: Issue #4182

Solution/Idea

Describe in plain English what you solved and how. For instance, Added start command to CRC so the user can create a VM and set-up a single-node OpenShift cluster on it with one command. It requires blablabla...

Proposed changes

List main as well as consequential changes you introduced or had to introduce.

  1. Unexpose ports on stop

Testing

gvyas-mac:crc gvyas$ crc status
CRC VM:          Running
MicroShift:      Running (v4.15.12)
RAM Usage:       1.829GB of 3.904GB
Disk Usage:      7.383GB of 16.1GB (Inside the CRC VM)
Cache Usage:     258.9GB
Cache Directory: /Users/gvyas/.crc/cache
gvyas-mac:crc gvyas$ lsof -i -P | grep LISTEN | grep :443
crc       52984 gvyas   27u  IPv6  0xf2aff1d332f2083      0t0  TCP *:443 (LISTEN)
gvyas-mac:crc gvyas$ crc stop
INFO Updating kernel args...                      
INFO Stopping the instance, this may take a few minutes... 
Stopped the instance
gvyas-mac:crc gvyas$ lsof -i -P | grep LISTEN | grep :443
gvyas-mac:crc gvyas$ 
gvyas-mac:crc gvyas$ crc status
CRC VM:          Running
MicroShift:      Running (v4.15.12)
RAM Usage:       1.825GB of 3.904GB
Disk Usage:      7.411GB of 16.1GB (Inside the CRC VM)
Cache Usage:     258.9GB
Cache Directory: /Users/gvyas/.crc/cache
gvyas-mac:crc gvyas$ crc config view
- consent-telemetry                     : no
- ingress-https-port                    : 7443
- preset                                : microshift
gvyas-mac:crc gvyas$ lsof -i -P | grep LISTEN | grep :7443
crc       52984 gvyas   33u  IPv6 0x69b90fc20609dcca      0t0  TCP *:7443 (LISTEN)
gvyas-mac:crc gvyas$ crc stop
INFO Updating kernel args...                      
INFO Stopping the instance, this may take a few minutes... 
Stopped the instance
gvyas-mac:crc gvyas$ lsof -i -P | grep LISTEN | grep :7443
gvyas-mac:crc gvyas$ 
openshift-ci[bot] commented 5 months ago

@vyasgun: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security 1c9617e51bbc0e69ebedb7ebedbaa00ebfaa9518 link false /test security
ci/prow/integration-crc 1c9617e51bbc0e69ebedb7ebedbaa00ebfaa9518 link true /test integration-crc

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
openshift-ci[bot] commented 5 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gbraad

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/crc-org/crc/blob/main/OWNERS)~~ [gbraad] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment