0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Deploy application in Kubernetes

0
Posted at
  1. set alias in powershell
    set-alias -name k -value kubectl
  2. Create pod manifest template
    k run tellhost --image=toka9988/tellhost --dry-run=client -o yaml >mypod.yaml
  3. Apply pod manifest file to create a pop
    k apply -f mypod.yaml
  4. Set up port-forward
    k port-forward tellhost 8080 tellhost is the pod name, the porxy will wait connect. Use another powershell terminal to test.
  5. show pod log
    k logs tellhost
    stream the application log in real-time to see each request as it comes in
    k logs tellhost -f --follow
    k logs tellhost --timestamps=true show log time of each line
  6. copy file between local PC and pods
    k cp tellhost:\etc\hosts hosts.txt
  7. Run command in Pod
    k exec tellhost -- ps aux
    k exec tellhost -it -- bash
  8. delete pod by name
    k delete pod tellhost3
    k delete pod tellhost2 --wait=false
  9. Creating an HTTP GET liveness probe
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: tellhost
  name: tellhost
spec:
  containers:
  - image: toka9988/tellhost
    name: tellhost
    ports:
    - containerPort: 8080
    livenessProbe:
      httpGet:
        path: /
        port: 8080
      initialDelaySeconds: 10
      periodSeconds: 5
      timeoutSeconds: 2
      failureThreshold: 3
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
  1. Using a startup probe
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: tellhost
  name: tellhost
spec:
  containers:
  - image: toka9988/tellhost
    name: tellhost
    ports:
    - containerPort: 8080
    startupProbe:
      httpGet:
        path: /
        port: http
      periodSeconds: 10
      failureThreshold: 12
    livenessProbe:
      httpGet:
        path: /
        port: 8080
      periodSeconds: 5
      timeoutSeconds: 2
      failureThreshold: 3
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?