##deployment nginx ``` apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: app: fresco-nginx-pod spec: replicas: 3 selector: matchLabels: app: fresco-nginx-pod template: metadata: labels: app: fresco-nginx-pod spec: containers: - name: fresco-nginx-container image: nginx:1.14.2 ports: - containerPort: 80 ``` ##working commands kubectl run firstapp image="gcr" --port=8080 kubectl expose pod firstapp --target-port=8080 --type=Nodeport ## kubectl create service nodeport my-ns --tcp=30007:8080 ## service yaml ``` apiVersion: v1 kind: Service metadata: name: my-service spec: type: NodePort selector: app: MyApp ports: # By default and for convenience, the `targetPort` is set to the same value as the `port` field. - port: 80 targetPort: 80 # Optional field # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767) nodePort: 30007 ``` ##kubeconfig map ``` apiVersion: v1 kind: ConfigMap metadata: name: fresco-config data: # property-like keys; each key maps to a simple value player_initial_lives: "3" ``` ### config POds ``` apiVersion: v1 kind: Pod metadata: name: fresco-nginx-pod spec: containers: - name: fresco-nginx-container image: nginx:1.14.2 command: ["sleep", "3600"] env: # Define the environment variable - name: SERVER_URL_ENV # Notice that the case is different here # from the key name in the ConfigMap. valueFrom: configMapKeyRef: name: fresco-config # The ConfigMap this value comes from. key: SERVER_URL # The key to fetch. ``` echo "user:admin" >>pass.txt echo "pass:password">>pass.txt ##createing secretes kubectl create secret generic fresco-secret \ --from-file=pass.txt \ ## Config POd ``` apiVersion: v1 kind: ConfigMap metadata: name: fresco-config data: SERVER_URL: "https://www.fresco.com" ##deploy pod with configmap apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx:latest command: ["sleep", "3600"] env: - name: SERVER_URL_ENV valueFrom: configMapKeyRef: name: fresCO-CONFIG key: SERVER_URL volumeMounts: - name: secret mountPath: "/etc/test" readOnly: true volumeMounts: - name: fresco-pv mountPath: "/usr/share/nginx/html" volumes: - name: config secret: secretName: fresco-secret volumes: - name: fresco-pv persistestVolumeClaim: claimName: fresco-pvc ``` ## create PV ``` apiVersion: v1 kind: PersistentVolume metadata: name: fresco-pv labels: type: local spec: storageClassName: manual capacity: storage: 100Mi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain hostPath: path: "/tmp/fresco" ``` ## PVC ``` apiVersion: v1 kind: PersistentVolumeClaim metadata: name: fresco-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 50Mi storageClassName: manual ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up