Skip to content

Commit

Permalink
Add k8s/namespace doc
Browse files Browse the repository at this point in the history
  • Loading branch information
difranca committed Jan 18, 2024
1 parent a8cfb92 commit 0d7978a
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/tech/cheats/Kubernetes/kubectl.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem';
Cheat sheet for kubectl commands.

:::info
This page was automatically generated from a navi cheat file available at [**difranca/navi-cheats**](https://github.com/difranca/navi-cheats).<br />
This page was automatically generated from a navi cheat file available at [**difranca/navi-cheats**](https://github.com/difranca/navi-cheats).<br/>
**Navi** is an interactive cheatsheet tool for the command-line. To learn more about it, visit [**denisidoro/navi**](https://github.com/denisidoro/navi).
:::

Expand Down
33 changes: 33 additions & 0 deletions docs/tech/cloud/kubernetes/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
keywords: [kubernetes, k8s, kubectl]
slug: /cloud/kubernetes
title: Kubernetes | Cloud | Tech-Notes
sidebar_label: Kubernetes
---

# Kubernetes

<br/>

<div style={{textAlign: 'center'}}>

<img width="200" height="200" alt="logo" src="/img/cloud/kubernetes.png"/>

_Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications._

</div>

:::note More Information

- https://www.kubernetes.io

:::

<br/>

## Index

import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';

<DocCardList items={useCurrentSidebarCategory().items}/>
80 changes: 80 additions & 0 deletions docs/tech/cloud/kubernetes/namespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
keywords: [kubernetes, k8s, kubectl, namespace]
title: Namespaces | Kubernetes | Cloud | Tech-Notes
sidebar_label: Namespaces
---

# Namespaces

Namespaces provides a mechanism for isolating groups of resources within a single cluster.

- Names of resources need to be unique within a namespace
- Namespace-based scoping is applicable only for namespaced objects and not for cluster-wide objects

:::note More Information

- https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

:::

<br/>

## Namespaces Stuck in Terminating

When deleting a namespace in Kubernetes, the namespace may remain stuck in terminating status.

```bash
$ kubectl get ns

NAME STATUS AGE
default Active 2d
kube-public Active 2d
kube-system Active 2d
my-namespace Terminating 7m
```

### Solution

1. Get the namespace manifest

```bash
$ kubectl get ns my-namespace -o yaml > namespace.yaml
```

2. Edit the manifest file and remove all finalizers

```yaml
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
spec:
finalizers:
status:
phase: Terminating
```
3. Start kubectl proxy
```bash
$ kubectl proxy

Starting to serve on 127.0.0.1:8001
```

4. Call namespace finalize API:

```bash
$ curl -H "Content-Type: application/yaml" -X PUT --data-binary @namespace.yaml http://127.0.0.1:8001/api/v1/namespaces/my-namespace/finalize
```

5. Confirm if namespace was deleted

```bash
$ kubectl get ns

NAME STATUS AGE
default Active 2d
kube-public Active 2d
kube-system Active 2d
``
Binary file added static/img/cloud/kubernetes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0d7978a

Please sign in to comment.