piątek, 18 stycznia 2019

Garbage Collector

When your nodes are running for some time you might find a lot of terminated containers and container images unreferenced by any pods consuming your container storage. In Docker environment you would execute docker rm and docker rmi to get rid of this objects. In Openshift alternatively you could leverage built in Garbage Collector which can do this for you automatically in the background. 

Garbage Collector is enabled by default in Openshift however with no limits for number of terminated containers and very high limits for unreferenced images storage space. You can adjust this defaults by setting kubeletArguments section of the node-config.yaml: 

kubeletArguments:

  ...
  maximum-dead-containers-per-container:
  - '1'
  maximum-dead-containers:
  - '50'
  minimum-container-ttl-duration:
  - 10s
  image-gc-high-threshold:
  - '70'
  image-gc-low-threshold:
  - '60'

You could learn more about this useful functionality in Openshift docs.





 

czwartek, 3 stycznia 2019

Deleting projects stuck in Terminating state

Sometimes you'll experience OpenShift projects stuck in Terminating state. One of the reasons could be your project has orphan serivceinstance or servicebinding objects. You can list this objects by calling explicitly oc get command:

$ oc get serviceinstance -n your_project_name
$ oc get servicebinding -n your_project_name

If this commands will return any objects you can get rid of them and likely get the project deleted automatically by OpenShift with following commands:

$ for i in $(oc get projects | grep Terminating | awk '{print $1}'); do echo $i; oc get serviceinstance -n $i -o yaml | sed "/kubernetes-incubator/d" | oc apply -f - ; done

$ for i in $(oc get projects | grep Terminating | awk '{print $1}'); do echo $i; oc get servicebinding -n $i -o yaml | sed "/kubernetes-incubator/d" | oc apply -f - ; done