Last active
March 30, 2025 03:53
-
-
Save khaosdoctor/3309c25b7155db7705c07fa4fb99e169 to your computer and use it in GitHub Desktop.
Scripts e comandos que eu faço no vídeo sobre KinD com Kubernetes: https://www.youtube.com/watch?v=dL19dSGKZoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kind create cluster --name demo-cluster | |
kind get clusters | |
kubectl config get-contexts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl apply -f ./9-deploy.yaml | |
kubectl get pods | |
kubectl logs deploy/api | |
kubectl port-forward service/api 3000:80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl get namespaces # ou kubectl get ns | |
kubectl get pods -n kube-system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kind delete cluster --name demo-cluster |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kind: Cluster | |
apiVersion: kind.x-k8s.io/v1alpha4 | |
nodes: | |
- role: control-plane | |
- role: worker | |
- role: worker | |
- role: worker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kind create cluster --name demo-cluster-3 --config ./4-kind-3-nodes.yml | |
kind get clusters | |
kubectl config get-contexts | |
kubectl get pods -n kube-system | |
kubectl get nodes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Crie o arquivo package.json com o comando npm init -y | |
import {createServer} from 'node:http' | |
const server = createServer((r, rs) => { | |
rs.writeHead(200, { 'Content-Type': 'application/json' }) | |
rs.end('Hello') | |
}) | |
server.listen(process.env.PORT || 3000, () => console.log(`Server running on port ${process.env.PORT || 3000}`)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t hello-api . | |
docker images |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kind load docker-image hello-api --name demo-cluster-3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: api | |
spec: | |
selector: | |
matchLabels: | |
app: api | |
template: | |
metadata: | |
labels: | |
app: api | |
spec: | |
containers: | |
- name: api | |
image: hello-api | |
imagePullPolicy: IfNotPresent | |
resources: | |
limits: | |
memory: "128Mi" | |
cpu: "500m" | |
ports: | |
- containerPort: 3000 | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: api | |
spec: | |
selector: | |
app: api | |
ports: | |
- port: 80 | |
targetPort: 3000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:18-alpine | |
EXPOSE 3000 | |
RUN mkdir /app | |
WORKDIR /app | |
COPY package.json index.mjs /app/ | |
ENTRYPOINT ["node", "index.mjs"] |
Thanks! It was a typo!
Hi, I'd like to share some fixes into file [9-deploy.yaml](https://gist.github.com/khaosdoctor/3309c25b7155db7705c07fa4fb99e169#file-9-deploy-yaml
- line 9, must be
template:
insteadtemplate
- line 34, I needed to change from
containerPort
totargetPort
. Without this changes, this error occur:Error from server (BadRequest): error when creating "deploy.yml": Service in version "v1" cannot be handled as a Service: strict decoding error: unknown field "spec.ports[0].containerPort"
Thanks! Updated!
Estou com esse erro, como resolver?
The connection to the server 172.31.68.87:6443 was refused - did you specify the right host or port?
Esse pode ser um erro de configuração do cluster, você consegue rodar algum outro comando?
Consigo sim! O Cluster funciona porém depois de alguns minutos esse erro
volta
Em sex., 16 de dez. de 2022 16:33, Lucas Santos ***@***.***>
escreveu:
… ***@***.**** commented on this gist.
------------------------------
Esse pode ser um erro de configuração do cluster, você consegue rodar
algum outro comando?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/3309c25b7155db7705c07fa4fb99e169#gistcomment-4405446>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWOJ3KHFHD5ZFHQWDFLWHQTWNS7YPBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCNZTGMZTOMBQU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
4-kind-3-nodes.yml
alter node for nodes, at least here in my maxina I had to do this