Tutorial ini akan bermanfaat jika Anda:
- Menghosting aplikasi di Cloud Run.
- Menggunakan Cloud SQL sebagai database Anda.
- Ingin menggunakan phpMyAdmin sebagai antarmuka untuk MySQL atau lebih suka antarmuka web untuk administrasi database.
Tujuan
- Pelajari cara men-deploy phpMyAdmin di Cloud Run.
Biaya
Tutorial ini menggunakan komponen Google Cloudyang dapat ditagih, termasuk:
Untuk membuat perkiraan biaya berdasarkan proyeksi penggunaan Anda, gunakan Kalkulator Harga.
Sebelum memulai
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- Buat instance Cloud SQL Generasi Kedua dengan IP pribadi.
- Buat pengguna database.
Membuat layanan menggunakan image phpMyAdmin
Konsol
Di konsol Google Cloud , buka Cloud Run:
Pilih Create service.
- Di kolom URL Container image, masukkan
phpmyadmin
. Cloud Run mengambil image dari Docker Hub publik. - Di kolom Nama layanan, masukkan
phpmyadmin
. - Periksa
Require authentication
. - Klik Container(s), volumes, networking, security
untuk menetapkan opsi berikut:
- Di kolom Port, masukkan
80
untuk nilai port penampung. - Di Variabel lingkungan, tambahkan
PMA_HOST
dan tetapkan nilainya sebagai alamat IP internal instance Cloud SQL.
- Di kolom Port, masukkan
Di Networking, pilih Connect to a VPC for outbound traffic dan Send traffic directly to a VPC. Pilih jaringan yang sama dengan instance Cloud SQL.
- Di kolom URL Container image, masukkan
Menghubungkan ke layanan menggunakan proxy Cloud Run
Untuk mengakses layanan yang dilindungi IAM dengan aman, gunakan proxy developer Cloud Run.
Untuk memulai proxy di layanan yang dibuat sebelumnya, gunakan perintah berikut:
gcloud run services proxy phpmyadmin --port=8080
Jika gcloud CLI meminta Anda untuk menginstal komponen
cloud-run-proxy
, masukkanY
.Untuk menguji penyiapan, masukkan URL dan nomor port (misalnya,
http://127.0.0.1:8080/
), lalu masukkan nama pengguna (nama admin) dan sandi. Karena Anda menggunakan proxy developer Cloud Run lokal untuk mengakses layanan dengan aman, Anda mungkin melihat pesan error, yang dapat diabaikan:There is a mismatch between HTTPS indicated on the server and client
.
Memecahkan masalah
Untuk mendapatkan informasi tentang error Cloud Run, akses log Cloud Run di konsol Google Cloud.
Pembersihan
Setelah menyelesaikan tutorial, Anda dapat membersihkan resource yang dibuat agar resource tersebut berhenti menggunakan kuota dan dikenai biaya. Bagian berikut menjelaskan cara menghapus atau menonaktifkan resource ini.
Menghapus project
Cara termudah untuk menghilangkan penagihan adalah dengan menghapus project yang Anda buat untuk tutorial.
Untuk menghapus project:
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
Menghapus instance
Untuk menghapus instance Cloud SQL:
- In the Google Cloud console, go to the Instances page.
- Click the name of the SQL instance you that want to delete.
- To delete the instance, click Delete, and then follow the instructions.
Langkah berikutnya
- Mempelajari phpMyAdmin lebih lanjut.
- Mempelajari arsitektur referensi, diagram, dan praktik terbaik tentang Google Cloud. Lihat Cloud Architecture Center kami.