Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devrel section to the docs #1124

Merged
merged 57 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e65bb77
Add devrel section to the docs
Feb 10, 2023
92a1e1b
Fix exclamation mark not allowed
Feb 13, 2023
79b16a6
Fix PR comments
Feb 13, 2023
40f56ac
Merge branch 'master' of https://github.com/spectrocloud/librarium in…
Apr 5, 2023
02f76e1
Add approved articles to docs
Apr 6, 2023
355a8e8
Fix spellings
Apr 6, 2023
d2766ec
Rename Kubernetes School with Kubernetes Knowlege hub
Apr 6, 2023
7b85c98
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
fb4fff7
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
bcd8af2
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
2cbfaf6
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
c7103f5
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
4e8dc5b
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
f5ee20e
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
9564500
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
8e52a6a
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
70df93e
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
66d8574
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
b38c346
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
b24e13e
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
4592e04
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
eccf8e7
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
2bf0c8c
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
e4ea7b6
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
b1a6b1d
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
aae3593
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
153a6d1
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
1d83483
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
88cf7d6
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
86199d4
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
e129593
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
6fd4d38
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
67ac8e3
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
066ecb4
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
1ea9b0e
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
d0d8ca5
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
d403a75
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
8801695
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
e10eb99
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
8773d9c
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
5196f58
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
ca149f2
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
2c26c32
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
f769352
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
43d81de
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
0c2fd60
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
fae5094
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
803370d
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 12, 2023
13d4356
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/06-deploy-st…
Princesso Apr 12, 2023
7f223b2
Update with PR comments
Princesso Apr 12, 2023
166b03a
Update with PR comments
Princesso Apr 12, 2023
36c0cb5
Merge branch 'master' into Doc-devrel-Create_Devrel_Section_On_Docs
Princesso Apr 12, 2023
a43b4f0
Apply suggestions from code review
karl-cardenas-coding Apr 13, 2023
4ae256a
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 13, 2023
143b13c
Update content/docs/19-kubernetes-knowlege-hub/01-tutorials.md
Princesso Apr 13, 2023
3648506
Update content/docs/19-kubernetes-knowlege-hub/00-how-to/02-how-to-re…
Princesso Apr 13, 2023
4aeafeb
Remove tutorial and community sections
Princesso Apr 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions content/docs/19-kubernetes-school.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "Kubernetes School"
metaTitle: "kubernetesschool"
metaDescription: "Kubernetes School Respository"
icon: "bookmark"
hideToCSidebar: true
hideToC: true
fullWidth: true
---

import Tabs from 'shared/components/ui/Tabs';
import WarningBox from 'shared/components/WarningBox';
import InfoBox from 'shared/components/InfoBox';
import PointsOfInterest from 'shared/components/common/PointOfInterest';
import Tooltip from "shared/components/ui/Tooltip";

# Welcome to the Spectro Cloud Knowledge Portal

Welcome to the Spectro Cloud Kubernetes School. You will find core Kubernetes tutorials, how-tos, frequently asked questions, and community curated resources.

If you have a topic in mind you would like to see, use the Feedback app on the lower-right-hand corner.
<br />

- [How-To](/kubernetes-school/how-to)


- [Tutorials](/kubernetes-school/tutorials)


- [Community](/kubernetes-school/community)


<br />
28 changes: 28 additions & 0 deletions content/docs/19-kubernetes-school/00-how-to.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "How to"
metaTitle: "Get started with a quick Kubernetes How-to"
metaDescription: "Kubernetes School with How to"
icon: "book"
hideToC: false
fullWidth: false
hiddenFromNav: false
---

import Tabs from 'shared/components/ui/Tabs';
import WarningBox from 'shared/components/WarningBox';
import InfoBox from 'shared/components/InfoBox';
import PointsOfInterest from 'shared/components/common/PointOfInterest';
import Tooltip from "shared/components/ui/Tooltip";

# How To

Learn about core Kubernetes concepts and how you can apply them on Spectro Cloud Palette.

# Core Kubernetes
- [How To Retrieve Images from a Private Registry in Kubernetes](/kubernetes-school/how-to/how-to-retrieve-images-from-private-registry)



- [Deploy a Stateless Frontend Application on Kubernetes](/kubernetes-school/how-to/deploy-stateless-frontend-app)

<br />
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
---
title: "Retrieve Images from a Private Registry"
metaTitle: "Retrieve Images from a Private Registry"
metaDescription: "Create a Kubernetes Secret"
icon: ""
hideToC: false
fullWidth: false
hiddenFromNav: false
---

import Tabs from 'shared/components/ui/Tabs';
import WarningBox from 'shared/components/WarningBox';
import InfoBox from 'shared/components/InfoBox';
import PointsOfInterest from 'shared/components/common/PointOfInterest';
import Tooltip from "shared/components/ui/Tooltip";

# How To Retrieve Images from a Private Registry in Kubernetes

Kubernetes is an open-source container orchestration platform that enables efficient management, deployment, and scaling of containerized applications.

By default, Docker and Kubernetes allow a limited number of unauthenticated pulls from a Docker registry, such as Docker Hub. Once you have exceeded this limit, you will not be able to pull any more images until the limit resets.

The limit is based on the IP address of the machine making the pulls, so it applies to all containers running on that machine.

To avoid this issue, it's recommended that you authenticate with the Docker registry before pulling images, especially if you are pulling from a private registry. This will ensure that you have access to the images you need and can pull them without any restrictions or limitations.

To log into a Docker registry from Kubernetes, you must create a secret containing your registry credentials. You can use this secret in a Kubernetes deployment configuration to pull images from the registry.

In this tutorial, you will log into a private docker registry to pull existing images of an application you will deploy in Kubernetes.

## Prerequisites

- The Kubectl [command-line tool](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/). Kubectl allows you to connect to, configure and work with your clusters through the command line.
Princesso marked this conversation as resolved.
Show resolved Hide resolved
Princesso marked this conversation as resolved.
Show resolved Hide resolved
- Access to a private registry. [DockerHub](https://hub.docker.com/) offers a single private registry on the free tier. If you do not have a personal registry account, you can use DockerHub.
- Access to a running Kubernetes cluster. Setting up a Kubernetes cluster can be difficult. You can read about how to [create one from scratch](https://www.notion.so/How-To-Create-a-Kubernetes-Cluster-bf707518b6bf4a918d8b11a570eabed6) or on [Spectro Cloud’s console.](https://docs.spectrocloud.com/getting-started/#deployingyourfirstcluster)

Below is an example of how you can create a secret and use it in a Kubernetes deployment:

## **Create a JSON File Containing your Credentials.**

First, create a file called **registry-creds.json** that contains your registry credentials in the following format:

```json
{
"auths": {
"example.registry.com": {
"username": "username",
"password": "password"
}
}
}
```

Keeping passwords in plain text is unsafe. Kubernetes automatically encodes passwords used to create a secret in base64. Encoding passwords does not mean your passwords cannot be decoded.

## **Create a Kubernetes Secret from the JSON File Containing the Secrets.**

Use the Kubectl command-line tool to generate a secret from the **registry-creds.json** file:
Princesso marked this conversation as resolved.
Show resolved Hide resolved

```bash
kubectl create secret generic myregistrykey --from-file=registry-creds.json
```

You can use the command below to view the secret created in detail.

```bash
kubectl get secret/myregistrykey -o json
```

The output of the command displays that the content of the **registry-creds.json** file is base 64 encoded.

```json
{
"apiVersion": "v1",
"data": {
"registry-creds.json": "ewogICJhdXRocyI6IHsKICAgICJleGFtcGxlLnJlZ2lzdHJ5LmNvbSI6IHsKICAgICAgInVzZXJuYW1lIjogInRlc3RfdXNlcm5hbWUiLAogICAgICAicGFzc3dvcmQiOiAidGVzdF9wYXNzd29yZCIKICAgIH0KICB9Cn0K"
},
"kind": "Secret",
"metadata": {
"creationTimestamp": "2023-03-22T08:44:26Z",
"name": "myregistrykey",
"namespace": "default",
"resourceVersion": "1552285",
"uid": "ccfb047b-67c8-446b-a69a-6eb762c3100f"
},
"type": "Opaque"
}
```

You will decode the secret you created to verify that secrets are not secure.

```bash
kubectl get secret myregistrykey -o jsonpath='{.data.registry-creds\.json}' | base64 --decode
```

The output of issuing the command above is the content of the json file you used to create the secret.
Princesso marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"auths": {
"example.registry.com": {
"username": "username",
"password": "password"
}
}
}
```

## **Add Secret to Deployment config.**

In your Kubernetes deployment configuration, specify the name of the secret you just created in the imagePullSecrets field:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: registry.example.com/my-image
imagePullSecrets:
- name: myregistrykey
```

## Apply the Deployment configuration To your Kubernetes cluster.

```bash
kubectl apply -f deployment.yaml
```

With this configuration in place, Kubernetes will use the registry credentials in the `myregistrykey` secret to log into the registry and pull the specified image when deploying the application.

## Other Ways To Authenticate To a Docker Registry from Kubernetes

An alternative way to log into a Docker registry from Kubernetes is by using the command line.

Authenticate to the private registry. Here’s an example of how to do this:

```bash
$ kubectl create secret docker-registry <secret-name> \
--docker-server=<registry-url> \
--docker-username=<username> \
--docker-password=<password> \
--docker-email=<email>
```

In the snippet above, **`<secret-name>`** refers to a unique name for the secret, **`<registry-url>`** is the URL of the private registry. Replace the **`<username>`** with the username for authentication and **`<password>`** with the password for authentication. Also, replace **`<email>`**
with the email associated with the authentication credentials.

Add the secret created in the previous step to the default service account with the following code.

```bash
$ kubectl patch serviceaccount default \
-p '{"imagePullSecrets": [{"name": "<secret-name>"}]}'
```

Replace **`<secret-name>`** with the secret created in the previous step.

Once you are authenticated and have added the secret to your default service account, you can use the Kubectl command to pull images from the registry and deploy them to your Kubernetes cluster like this:
Princesso marked this conversation as resolved.
Show resolved Hide resolved

```bash
$ kubectl run <deployment-name> \
--image=<registry-url>/<image-name>:<tag> \
--port=<container-port>
```

The line above will create a new deployment using the image specified from the private registry.

# Next Steps

In conclusion, accessing images from a private registry in Kubernetes can be challenging due to the need to authenticate with the registry.

To solve this challenge, you have learned how to create a Kubernetes secret with your Docker registry credentials and use it in a Kubernetes deployment configuration. This allows you to pull images from your private registry without restrictions or limitations.

To learn more about Kubernetes and how to use it to deploy your application, you can visit [our documentation.](https://docs.spectrocloud.com/) You can also read about [how to deploy a stateless frontend application](https://www.notion.so/How-To-Deploy-A-Stateless-Frontend-App-with-Kubernetes-b885ae2307e94ef191a1b713fe29c81f) on Kubernetes or join our [slack channel](https://join.slack.com/t/spectrocloudcommunity/shared_invite/zt-1mw0cgosi-hZJDF_1QU77vF~qNJoPNUQ) to have exciting conversations on Kubernetes with our community members.
Loading