kubectl create ns phpinfo
kubectl create secret generic index.php --from-literal=index.php='<?php phpinfo();?>' --namespace phpinfo
kubectl get secret index.php --namespace phpinfo --output yaml
echo PD9waHAgcGhwaW5mbygpOz8+ | base64 --decode
- https://kubernetes.io/docs/home/
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#secret-v1-core
# secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: phpinfo-secret
namespace: phpinfo
stringData:
index.php: <?php phpinfo();?>
type: Opaque
# kubectl apply --filename secret.yaml --namespace phpinfo
# kubectl get secret phpinfo-secret --namespace phpinfo --output yaml
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#configmap-v1-core
# cm.yaml
apiVersion: v1
data:
index.php: <?php phpinfo();?>
kind: ConfigMap
metadata:
name: phpinfo-cm
namespace: phpinfo
# kubectl apply --filename cm.yaml --namespace phpinfo
# kubectl get cm phpinfo-cm --namespace phpinfo --output yaml
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#service-v1-core
# svc.yaml
apiVersion: v1
kind: Service
metadata:
name: phpinfo
namespace: phpinfo
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8080
selector:
app: phpinfo
type: NodePort
# kubectl apply --filename svc.yaml --namespace phpinfo
kubectl api-resources | grep -E "DaemonSet|CronJob|Job|pods.*po.*true.*Pod|StatefulSet|ReplicationController|ReplicaSet|Deployment"
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#pod-v1-core
# po.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
app: phpinfo
name: phpinfo-po
namespace: phpinfo
spec:
containers:
- args:
- -f
- index.php
- -S
- 0.0.0.0:8080
command:
- php
image: php:alpine
name: phpinfo-container
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: /app/index.php
name: phpinfo-volume
readOnly: true
subPath: index.php
workingDir: /app/
restartPolicy: Always
securityContext:
runAsUser: 65534
volumes:
- name: phpinfo-volume
secret:
defaultMode: 0444
items:
- key: index.php
mode: 0444
path: index.php
secretName: phpinfo-secret
# kubectl apply --filename po.yaml --namespace phpinfo
# kubectl get po --namespace phpinfo
# kubectl logs phpinfo-po --namespace phpinfo
# kubectl exec phpinfo-po --namespace phpinfo -- ls -l
# kubectl exec phpinfo-po --namespace phpinfo -- curl localhost:8080 -I -s
# kubectl describe po phpinfo-po --namespace phpinfo
# kubectl describe svc phpinfo --namespace phpinfo
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#replicationcontroller-v1-core
# rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: phpinfo-rc
namespace: phpinfo
spec:
replicas: 2
selector:
app: phpinfo
template:
metadata:
labels:
app: phpinfo
spec:
containers:
- args:
- -f
- index.php
- -S
- 0.0.0.0:8080
command:
- php
image: php:alpine
name: phpinfo-container
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: /app/index.php
name: phpinfo-volume
readOnly: true
subPath: index.php
workingDir: /app/
restartPolicy: Always
securityContext:
runAsUser: 65534
volumes:
- name: phpinfo-volume
secret:
defaultMode: 0444
items:
- key: index.php
mode: 0444
path: index.php
secretName: phpinfo-secret
# kubectl apply --filename rc.yaml --namespace phpinfo
# kubectl exec phpinfo-rc-kk8z5 --namespace phpinfo -- curl localhost:8080 -sI
# kubectl exec phpinfo-rc-kk8z5 --namespace phpinfo -- curl 10.106.46.99 -sI
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#replicasetspec-v1-apps
# rs.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: phpinfo-rs
namespace: phpinfo
spec:
replicas: 2
selector:
matchLabels:
app: phpinfo
template:
metadata:
labels:
app: phpinfo
spec:
containers:
- args:
- -f
- index.php
- -S
- 0.0.0.0:8080
command:
- php
image: php:alpine
name: phpinfo-container
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: /app/index.php
name: phpinfo-volume
readOnly: true
subPath: index.php
workingDir: /app/
restartPolicy: Always
securityContext:
runAsUser: 65534
volumes:
- name: phpinfo-volume
secret:
defaultMode: 0444
items:
- key: index.php
mode: 0444
path: index.php
secretName: phpinfo-secret
# kubectl apply --filename rs.yaml --namespace phpinfo
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#daemonset-v1-apps
# ds.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: phpinfo-ds
namespace: phpinfo
spec:
selector:
matchLabels:
app: phpinfo
template:
metadata:
labels:
app: phpinfo
spec:
containers:
- args:
- -f
- index.php
- -S
- 0.0.0.0:8080
command:
- php
image: php:alpine
name: phpinfo-container
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: /app/index.php
name: phpinfo-volume
readOnly: true
subPath: index.php
workingDir: /app/
restartPolicy: Always
securityContext:
runAsUser: 65534
volumes:
- name: phpinfo-volume
secret:
defaultMode: 0444
items:
- key: index.php
mode: 0444
path: index.php
secretName: phpinfo-secret
# kubectl apply --filename ds.yaml --namespace phpinfo