Image Confidential Space

Image Confidential Space adalah OS minimal bertujuan tunggal yang dijalankan di instance Confidential VM. Batch dirancang untuk menjalankan satu workload hanya sekali, tanpa penyimpanan persisten. Workload tersebut dilapisi di atas image Confidential Space menggunakan Docker.

Image Confidential Space di-build berdasarkan peningkatan keamanan yang ada dari Container-Optimized OS dan menambahkan manfaat berikut:

  • Partisi disk terenkripsi dengan perlindungan integritas

  • Koneksi jaringan yang terautentikasi dan terenkripsi

  • Berbagai pengukuran booting

  • Akses jarak jauh dan alat khusus cloud dinonaktifkan

Jenis gambar

Image Confidential Space tersedia dalam dua varian:

  • Produksi: Image produksi digunakan untuk menjalankan workload produksi sebenarnya dengan data produksi sebenarnya. Lingkungan ini dikunci untuk mencegah operator workload mengakses data yang diproses. Untuk mengetahui informasi selengkapnya, lihat Ringkasan keamanan Confidential Space.

  • Debug: Image debug digunakan untuk menguji workload Anda pada data non-produksi. SSH diaktifkan pada image debug, dan operator memiliki akses root ke VM yang menjalankan workload. VM yang menjalankan image debug tidak berhenti setelah workload selesai.

Anda dapat menetapkan jenis image yang akan digunakan saat men-deploy workload.

Melihat image Confidential Space

Anda dapat melihat image Confidential Space yang tersedia dengan perintah gcloud berikut:

gcloud compute images list \
    --project=confidential-space-images \
    --no-standard-images

Flag berikut dapat mengubah gambar yang ditampilkan dalam hasil:

  • Tambahkan flag --filter="family~'confidential-space$'" untuk menampilkan image produksi.

  • Tambahkan flag --filter="family~'confidential-space-debug$'" untuk menampilkan gambar debug.

Melihat image yang tidak digunakan lagi

Jalankan perintah berikut untuk menyertakan image yang tidak digunakan lagi dalam hasil, beserta kolom tambahan yang dapat membantu menginformasikan pengambilan keputusan:

gcloud compute images list \
    --project=confidential-space-images \
    --no-standard-images \
    --show-deprecated \
    --filter="name ~ '^confidential-space-[0-9]{6}$'" \
    --format="table(
      name,
      creationTimestamp.date('%Y-%m-%d'):label=CREATION_DATE,
      status,
      description.sub('.*COS: ', '').sub(',.*', ''):label=COS_VERSION,
      deprecated.state:label=STATE,
      deprecated.deprecated:label=DEPRECATE_ON,
      deprecated.obsolete:label=OBSOLETE_ON,
      deprecated.replacement
    )"

Respons yang berhasil akan terlihat seperti berikut:

NAME                       CREATION_DATE  STATUS  COS_VERSION               STATE       DEPRECATE_ON  OBSOLETE_ON  REPLACEMENT
confidential-space-230600  2023-06-09     READY   cos-dev-109-17637-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-230901
confidential-space-230900  2023-09-17     READY   cos-dev-109-17637-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-230600
confidential-space-230901  2023-10-02     READY   cos-dev-113-17877-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-231001
confidential-space-231001  2023-11-01     READY   cos-dev-113-17965-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-231100
confidential-space-231100  2023-11-17     READY   cos-dev-113-18026-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-231200
confidential-space-231200  2023-12-04     READY   cos-dev-113-18054-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-231201
confidential-space-231201  2023-12-15     READY   cos-dev-113-18059-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-240200
confidential-space-240200  2024-02-28     READY   cos-dev-113-18146-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-240402
confidential-space-240402  2024-04-22     READY   cos-dev-117-18342-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-240500
confidential-space-240500  2024-05-30     READY   cos-dev-117-18374-0-0     DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-240700
confidential-space-240700  2024-07-30     READY   cos-113-18244-85-54       DEPRECATED                             https://www.googleapis.com/compute/v1/projects/confidential-space-images/global/images/confidential-space-240800
confidential-space-240800  2024-09-03     READY   cos-113-18244-151-14
confidential-space-240900  2024-10-01     READY   cos-113-18244-151-80
confidential-space-241000  2024-10-18     READY   cos-113-18244-151-96
...

Siklus proses image Confidential Space

Saat Anda membuat Confidential VM menggunakan kelompok image Confidential Space, versi terbaru image Confidential Space akan digunakan. Jika Anda selalu menghapus Confidential VM saat workload selesai dan membuat yang baru setiap kali menjalankan workload, Anda dapat yakin bahwa image tersebut sudah yang terbaru.

Namun, workload yang berjalan lama atau menjalankan workload pada VM yang dibuat di masa lalu akan membuat Anda berisiko menggunakan image Confidential Space yang sudah usang, yang dapat menimbulkan kerentanan keamanan.

Untuk mengurangi risiko ini, kolaborator data dapat menggunakan atribut dukungan untuk memeriksa apakah versi image Confidential Space produksi yang berjalan di VM adalah versi terbaru, dan menolak akses ke datanya jika tidak lulus. Image Confidential Space debug tidak memiliki atribut dukungan yang ditetapkan.

Tabel berikut menjelaskan atribut dukungan yang ditemukan pada image Confidential Space produksi.

Atribut dukungan Deskripsi

LATEST

Image LATEST juga memiliki atribut dukungan berikut:

  • STABLE
  • USABLE

Masa aktif image: Sekitar satu bulan. Setelah itu, atribut dukungan LATEST akan dihapus.

Ini adalah versi terbaru image Confidential Space, serta didukung dan dipantau untuk mengetahui kerentanannya.

Untuk workload yang berjalan lama, sebaiknya jangan tentukan LATEST sebagai bagian dari kebijakan pengesahan Anda. Hal ini karena image Confidential Space mungkin diperbarui saat workload Anda berjalan, sehingga image Confidential Space yang Anda gunakan tidak lagi LATEST, dan menyebabkan workload Anda gagal dalam pengesahan saat token default Confidential Space diperbarui berikutnya.

STABLE

Image STABLE juga memiliki atribut dukungan berikut:

  • USABLE

Masa aktif gambar: Sekitar enam bulan. Mulai 1 April 2027, atribut dukungan STABLE akan dihapus setelah masa aktif image berakhir.

Image dengan atribut STABLE didukung dan dipantau untuk mengetahui kerentanan selama periode enam bulan. Sebaiknya tulis kebijakan pengesahan berdasarkan atribut STABLE.

Dalam kasus yang jarang terjadi, atribut STABLE dapat dihapus selama periode dukungan normal enam bulan, seperti saat kerentanan kritis ditemukan.

USABLE

Gambar yang hanya memiliki atribut USABLE masih dapat digunakan, tetapi dianggap tidak digunakan lagi. Image yang tidak digunakan lagi tidak didukung, dan berusia lebih dari enam bulan. Risiko dari penggunaan versi ini merupakan tanggung jawab Anda sendiri.

Image USABLE memiliki properti deprecated.deprecated. Nilainya adalah stempel waktu kapan image diperkirakan akan dihentikan penggunaannya. Properti image dapat dilihat dengan perintah gcloud compute images describe, atau dengan metode REST images.get. Contoh:

gcloud compute images describe confidential-space-240800 \
    --format=json \
    --project=confidential-space-images
EXPERIMENTAL

Gambar yang hanya memiliki atribut ini akan menggunakan fitur pratinjau. Image EXPERIMENTAL hanya ditujukan untuk tujuan pengujian, dan tidak boleh digunakan dalam produksi.

Gambar EXPERIMENTAL tidak pernah memiliki atribut LATEST, STABLE, atau USABLE.

Sebaiknya selalu update image Confidential Space Anda. Untuk mempelajari cara mengupdate image Confidential Space, lihat Mengupdate image Confidential Space.

Memantau image yang tidak digunakan lagi

Untuk memantau instance VM yang menjalankan image Confidential Space yang tidak digunakan lagi atau akan segera tidak digunakan lagi, Anda dapat men-deploy fungsi Cloud Run yang dijalankan secara rutin dengan tugas Cloud Scheduler. Kemudian, Anda dapat menyiapkan notifikasi Cloud Logging untuk memberi tahu Anda saat image tidak digunakan lagi.

Men-deploy fungsi Cloud Run untuk memeriksa image yang tidak digunakan lagi

Untuk menyiapkan fungsi Cloud Run, selesaikan petunjuk berikut:

  1. Di Cloud Run, buka halaman Services.

    Buka Layanan

  2. Klik Write a function.

  3. Di kotak Service name, masukkan nama untuk fungsi.

  4. Pilih region untuk menjalankan fungsi.

  5. Tetapkan Runtime ke versi Go terbaru.

  6. Tetapkan Authentication ke Require authentication.

  7. Tetapkan Ingress ke Internal.

  8. Luaskan bagian Containers, Networking, Security.

  9. Di tab Containers, tetapkan Memory ke 128 MiB.

  10. Di tab Security, klik kotak Service account.

  11. Klik Buat akun layanan baru.

  12. Masukkan nama di kotak Service account name.

  13. Klik Create.

  14. Tambahkan peran Compute Viewer, lalu klik Done.

  15. Klik Create.

  16. Setelah fungsi dimuat, di tab Source, tetapkan Function entry point ke DeprecationCheck.

  17. Timpa konten di function.go dengan kode berikut:

    // Package imagechecker provides a function to check for deprecated CS images.
    package imagechecker
    
    import (
    	"context"
    	"encoding/json"
    	"fmt"
    	"log"
    	"log/slog"
    	"net/http"
    	"regexp"
    	"strings"
    	"time"
    
    	"cloud.google.com/go/compute/metadata"
    	"google.golang.org/api/compute/v1"
    	"github.com/GoogleCloudPlatform/functions-framework-go/functions"
    )
    
    const (
    	sourceImageProject  = "confidential-space-images"
    	deprecationValueFmt = "2006-01-02"
    )
    
    // CS Images have the format confidential-space-.*.
    var prodImageNameRegex = regexp.MustCompile(`^confidential-space-.*`)
    
    // VMInfo represents the information logged about an VM instance of note.
    type VMInfo struct {
    	Name            string `json:"instance_name"`
    	Zone            string `json:"instance_zone"`
    	ImageName       string `json:"image_name"`
    	DeprecationDate string `json:"image_deprecation_date,omitempty"`
    	ObsoleteDate    string `json:"image_obsolete_date,omitempty"`
    }
    
    // VMList represents a list of notable VMs and their relevance.
    type VMList struct {
    	Description string   `json:"description"`
    	Instances   []VMInfo `json:"instances"`
    }
    
    // LogPayload is the payload for Cloud Logs written by this job.
    type LogPayload struct {
    	Message            string  `json:"message"`
    	Obsolete           *VMList `json:"vms_obsolete"`
    	ObsoleteWarning    *VMList `json:"vms_obsolete_warning"`
    	Deprecated         *VMList `json:"vms_deprecated"`
    	DeprecationWarning *VMList `json:"vms_deprecation_warning"`
    }
    
    // LogEntry represents a Cloud Logging entry.
    type LogEntry struct {
    	Message   string      `json:"message"`
    	Severity  string      `json:"severity"` // Special field for Cloud Logging.
    	Payload   *LogPayload `json:"payload,omitempty"`
    	ProjectID string      `json:"projectId"`
    }
    
    func init() {
    	log.SetFlags(0)
    	functions.HTTP("DeprecationCheck", checkForDeprecations)
    }
    
    func checkForDeprecations(w http.ResponseWriter, r *http.Request) {
    	ctx := context.Background()
    
    	// Retrieve project ID.
    	projectID, err := metadata.ProjectIDWithContext(ctx)
    	if err != nil {
    		errMsg := fmt.Sprintf("Failed to get project ID from metadata server: %v", err)
    		logError(projectID, errMsg)
    		http.Error(w, errMsg, http.StatusInternalServerError)
    		return
    	}
    	slog.Info(fmt.Sprintf("Checking for project: %s", projectID))
    
    	// Configure compute service.
    	computeService, err := compute.NewService(ctx)
    	if err != nil {
    		msg := fmt.Sprintf("Failed to create compute service: %v", err)
    		logError(projectID, msg)
    		http.Error(w, msg, http.StatusInternalServerError)
    		return
    	}
    
    	var obsoleteVMs []VMInfo           // Will contain VMs whose images are obsolete.
    	var obsoleteWarningVMs []VMInfo    // Will contain VMs using an image that will be obsolete within a month.
    	var deprecatedVMs []VMInfo         // Will contain VMs whose images are deprecated.
    	var deprecationWarningVMs []VMInfo // Will contain VMs using an image that will be deprecated within a month.
    	now := time.Now()
    
    	pageFunc := instancesPageFunc(ctx, projectID, &obsoleteVMs, &obsoleteWarningVMs, &deprecatedVMs, &deprecationWarningVMs, now, computeService)
    	if err = computeService.Instances.AggregatedList(projectID).Pages(ctx, pageFunc); err != nil {
    		msg := fmt.Sprintf("Failed to list instances: %v", err)
    		logError(projectID, msg)
    		http.Error(w, msg, http.StatusInternalServerError)
    		return
    	}
    
    	if len(obsoleteVMs) == 0 && len(obsoleteWarningVMs) == 0 && len(deprecatedVMs) == 0 && len(deprecationWarningVMs) == 0 {
    		returnmsg := "No VMs using obsolete or deprecated images found."
    		logEntry := LogEntry{
    			Message:   "Confidential Space Image Deprecation Alert - No Issues Detected",
    			Severity:  "INFO",
    			ProjectID: projectID,
    			Payload:   &LogPayload{Message: returnmsg},
    		}
    		writeLog(logEntry)
    
    		w.WriteHeader(http.StatusOK)
    		_, err := w.Write([]byte(returnmsg))
    		if err != nil {
    			http.Error(w, fmt.Sprintf("Failed to write HTTP response: %v", err), http.StatusInternalServerError)
    		}
    		return
    	}
    
    	respPayload := &LogPayload{
    		Message: "The following instances are using Confidential Space images that are obsolete, deprecated, or will be obsolete/deprecated soon. Obsolete and deprecated images are no longer maintained and scanned for vulnerabilities. Please review these instances and update their boot images as needed.",
    	}
    
    	if len(obsoleteVMs) > 0 {
    		respPayload.Obsolete = &VMList{
    			Description: "Instances using CS images that are obsolete.",
    			Instances:   obsoleteVMs,
    		}
    	}
    	if len(obsoleteWarningVMs) > 0 {
    		respPayload.ObsoleteWarning = &VMList{
    			Description: "Instances using CS images that will be obsolete within a month.",
    			Instances:   obsoleteWarningVMs,
    		}
    	}
    	if len(deprecatedVMs) > 0 {
    		respPayload.Deprecated = &VMList{
    			Description: "Instances using CS images that are deprecated.",
    			Instances:   deprecatedVMs,
    		}
    	}
    	if len(deprecationWarningVMs) > 0 {
    		respPayload.DeprecationWarning = &VMList{
    			Description: "Instances using CS images that will be deprecated within a month.",
    			Instances:   deprecationWarningVMs,
    		}
    	}
    
    	entry := LogEntry{
    		Message:   "Confidential Space Image Deprecation Alert",
    		Severity:  "WARNING",
    		ProjectID: projectID,
    		Payload:   respPayload,
    	}
    
    	writeLog(entry)
    
    	w.Header().Set("Content-Type", "application/json")
    	w.WriteHeader(http.StatusOK)
    	err = json.NewEncoder(w).Encode(respPayload)
    	if err != nil {
    		http.Error(w, fmt.Sprintf("Failed to write HTTP response: %v", err), http.StatusInternalServerError)
    		return
    	}
    }
    
    func instancesPageFunc(ctx context.Context, projectID string, obsoleteVMs *[]VMInfo, obsoleteWarningVMs *[]VMInfo, deprecatedVMs *[]VMInfo, deprecationWarningVMs *[]VMInfo, now time.Time, computeService *compute.Service) func(list *compute.InstanceAggregatedList) error {
    	return func(list *compute.InstanceAggregatedList) error {
    		for _, instanceList := range list.Items {
    			for _, instances := range instanceList.Instances {
    				sourceImage, err := getSourceImage(ctx, projectID, instances, computeService)
    				if err != nil {
    					slog.Warn(fmt.Sprintf("Failed to get source image for instance %s: %v", instances.Name, err))
    					continue
    				}
    
    				// Skip instance if not using a CS prod image.
    				imageProject, imageName := parseImage(sourceImage)
    				if imageProject != sourceImageProject || !prodImageNameRegex.MatchString(imageName) {
    					continue
    				}
    
    				// Get deprecation status ("deprecate-on" / "obsolete-on" / state settings).
    				depStatus, err := getDeprecationStatus(ctx, imageProject, imageName, computeService)
    				if err != nil {
    					slog.Error(fmt.Sprintf("Failed to get deprecation status for image %s in project %s: %v", imageName, imageProject, err))
    					continue
    				}
    				if depStatus == nil {
    					continue
    				}
    
    				vm := VMInfo{
    					Name:      instances.Name,
    					Zone:      getResourceName(instances.Zone),
    					ImageName: imageName,
    				}
    
    				var depTime, obsTime time.Time
    				if depStatus.Deprecated != "" {
    					depTime, err = parseDeprecationDate(depStatus.Deprecated)
    					if err != nil {
    						slog.Error(fmt.Sprintf("Failed to parse deprecation date %s for image %s in project %s: %v", depStatus.Deprecated, imageName, imageProject, err))
    						continue
    					}
    					vm.DeprecationDate = depTime.Format(deprecationValueFmt)
    				}
    
    				if depStatus.Obsolete != "" {
    					obsTime, err = parseDeprecationDate(depStatus.Obsolete)
    					if err != nil {
    						slog.Error(fmt.Sprintf("Failed to parse obsolete date %s for image %s in project %s: %v", depStatus.Obsolete, imageName, imageProject, err))
    						continue
    					}
    					vm.ObsoleteDate = obsTime.Format(deprecationValueFmt)
    				}
    
    				// Determine whether instance image is obsolete, upcoming obsolete, deprecated, or upcoming deprecated.
    				if depStatus.State == "OBSOLETE" || (!obsTime.IsZero() && isPast(obsTime, now)) {
    					*obsoleteVMs = append(*obsoleteVMs, vm)
    				} else if !obsTime.IsZero() && isWarning(obsTime, now) {
    					*obsoleteWarningVMs = append(*obsoleteWarningVMs, vm)
    				} else if depStatus.State == "DEPRECATED" || (!depTime.IsZero() && isPast(depTime, now)) {
    					*deprecatedVMs = append(*deprecatedVMs, vm)
    				} else if !depTime.IsZero() && isWarning(depTime, now) {
    					*deprecationWarningVMs = append(*deprecationWarningVMs, vm)
    				}
    			}
    		}
    
    		return nil
    	}
    }
    
    func getSourceImage(ctx context.Context, projectID string, instance *compute.Instance, service *compute.Service) (string, error) {
    	for _, disk := range instance.Disks {
    		// Only check boot disk.
    		if disk.Boot {
    			// Retrieve source image for disk.
    			diskName := getResourceName(disk.Source)
    			zone := getResourceName(instance.Zone)
    
    			d, err := service.Disks.Get(projectID, zone, diskName).Context(ctx).Do()
    			if err != nil {
    				slog.Warn(fmt.Sprintf("Failed to get details for disk %s in zone %s: %v", diskName, zone, err))
    				continue
    			}
    
    			if d.SourceImage != "" {
    				return d.SourceImage, nil
    			}
    		}
    	}
    
    	return "", fmt.Errorf("no suitable source image name found for instance %s", instance.Name)
    }
    
    func getDeprecationStatus(ctx context.Context, imageProject, imageName string, service *compute.Service) (*compute.DeprecationStatus, error) {
    	image, err := service.Images.Get(imageProject, imageName).Context(ctx).Do()
    	if err != nil {
    		slog.Warn(fmt.Sprintf("Failed to get details for image %s in project %s: %v", imageName, imageProject, err))
    		return nil, err
    	}
    
    	if image.Deprecated == nil || (image.Deprecated.Deprecated == "" && image.Deprecated.Obsolete == "" && image.Deprecated.State == "") {
    		// Skip if no deprecation/obsolete setting.
    		slog.Warn(fmt.Sprintf("Image %s in project %s has no deprecate-on or obsolete-on setting", imageName, imageProject))
    		return nil, nil
    	}
    
    	return image.Deprecated, nil
    }
    
    func parseDeprecationDate(dateStr string) (time.Time, error) {
    	formats := []string{
    		time.RFC3339,
    		time.RFC3339Nano,
    		"2006-01-02T15:04:05",
    		"2006-01-02",
    		"2006-01",
    	}
    	for _, format := range formats {
    		if t, err := time.Parse(format, dateStr); err == nil {
    			return t, nil
    		}
    	}
    	return time.Time{}, fmt.Errorf("unable to parse %q as a valid deprecation date", dateStr)
    }
    
    func isPast(obsTime time.Time, now time.Time) bool {
    	return !obsTime.After(now)
    }
    
    func isWarning(targetTime time.Time, now time.Time) bool {
    	warningWindowEnd := now.AddDate(0, 1, 0)
    	return targetTime.After(now) && !targetTime.After(warningWindowEnd)
    }
    
    func parseImage(image string) (string, string) {
    	parts := strings.Split(image, "/")
    
    	var project, imageName string
    	for i, part := range parts {
    		if part == "projects" && i+1 < len(parts) {
    			project = parts[i+1]
    		} else if part == "images" && i+1 < len(parts) {
    			imageName = parts[i+1]
    		}
    	}
    
    	slog.Info(fmt.Sprintf("Source image project: %s, name: %s", project, imageName))
    
    	return project, imageName
    }
    
    // getResourceName extracts the last part of a GCP resource URL.
    func getResourceName(url string) string {
    	parts := strings.Split(url, "/")
    	return parts[len(parts)-1]
    }
    
    func writeLog(entry LogEntry) {
    	jsonData, err := json.Marshal(entry)
    	if err != nil {
    		slog.Warn(fmt.Sprintf("Error marshaling final log: %v", err))
    		slog.Warn(fmt.Sprintf("Log contents: %v", entry))
    		return
    	}
    
    	fmt.Println(string(jsonData))
    }
    
    func logError(projectID, errMsg string) {
    	entry := LogEntry{
    		Message:   "Confidential Space Image Deprecation Alert - Job Failed",
    		Severity:  "ERROR",
    		ProjectID: projectID,
    		Payload: &LogPayload{
    			Message: errMsg,
    		},
    	}
    
    	writeLog(entry)
    }
    
    
  18. Timpa konten di go.mod dengan kode berikut:

    module example.com/imagechecker
    
    require (
        cloud.google.com/go/compute/metadata v0.5.0
        github.com/GoogleCloudPlatform/functions-framework-go v1.9.0
        google.golang.org/api v0.264.0
    )
    
    
  19. Klik Save and redeploy.

  20. Setelah layanan berhasil di-deploy, catat URL-nya—yang ditemukan di dekat nama fungsi—untuk digunakan nanti.

Menyiapkan tugas Cloud Scheduler

Untuk menyiapkan tugas Cloud Scheduler yang menjalankan fungsi Cloud Run, selesaikan petunjuk berikut:

  1. Pertama, buat akun layanan untuk menjalankan tugas terjadwal. Untuk melakukannya, buka halaman Membuat Akun Layanan:

    Buka Create a Service Account

  2. Di kotak Service account name, tambahkan nama akun layanan.

  3. Catat ID akun layanan untuk digunakan nanti.

  4. Klik Create and continue.

  5. Tambahkan peran Cloud Run Invoker.

  6. Klik Done.

  7. Jika Anda belum melakukannya, aktifkan Cloud Scheduler API.

  8. Di Cloud Scheduler, buka halaman Jobs.

    Buka Tugas

  9. Klik Buat tugas.

  10. Di kolom Name, masukkan nama untuk tugas.

  11. Pilih region untuk menjalankan tugas terjadwal.

  12. Tambahkan jadwal cron ke kolom Frequency. Misalnya, 0 9 1 * * menjalankan tugas pada pukul 09.00 pada tanggal satu setiap bulan.

  13. Tetapkan zona waktu untuk jadwal.

  14. Klik Lanjutkan.

  15. Tetapkan Target type ke HTTP.

  16. Tetapkan URL ke URL fungsi Cloud Run yang Anda buat.

  17. Di kotak Auth header, pilih Add OIDC token.

  18. Klik kotak Service account, dan masukkan ID akun layanan yang Anda buat sebelumnya.

  19. Tetapkan audiens ke URL fungsi Cloud Run yang Anda buat

  20. Klik Create.

  21. Untuk menguji tugas, klik Actions, lalu klik Force run.

Menyiapkan pemberitahuan berbasis log

Untuk menyiapkan pemberitahuan berbasis log tentang image yang tidak digunakan lagi, selesaikan petunjuk berikut:

  1. Buka halaman Logs Explorer:

    Buka Logs Explorer

  2. Aktifkan Show query.

  3. Di kotak kueri, masukkan salah satu kueri Logging Query Language berikut:

    • VM yang ditemukan dengan penghentian mendatang:

      resource.type="cloud_run_revision"
      severity="WARNING"
      jsonPayload.message="Confidential Space Image Deprecation Alert"
      
    • Kegagalan pemeriksaan penghentian penggunaan:

      resource.type="cloud_run_revision"
      severity="ERROR"
      jsonPayload.message="Confidential Space Image Deprecation Alert - Job Failed"
      
    • Tidak ada image yang tidak digunakan lagi yang terdeteksi di fleet VM Anda:

      resource.type="cloud_run_revision"
      severity="INFO"
      jsonPayload.message="Confidential Space Image Deprecation Alert - No Issues Detected"
      
  4. Klik Run query.

  5. Di dekat hasil, klik Tindakan.

  6. Klik Create log alert, lalu selesaikan proses untuk membuat kebijakan pemberitahuan berdasarkan kueri yang Anda masukkan.

Memperbarui image Confidential Space

Untuk membantu menjaga image Confidential Space Anda tetap terbaru dan menghindari gangguan, sebaiknya buat instance Confidential VM baru setiap kali Anda meluncurkan workload Confidential Space. Setiap kali Anda membuat instance baru berdasarkan image Confidential Space, image Confidential Space terbaru akan disediakan.

Jika Anda tidak dapat membuat instance Confidential VM baru untuk setiap eksekusi workload Confidential Space, sebaiknya tentukan masa pemeliharaan untuk membuat ulang instance Confidential VM berdasarkan atribut dukungan yang telah ditetapkan oleh pihak tepercaya dalam kebijakan pengesahannya:

  • Jika Anda telah menetapkan kebijakan pengesahan yang memerlukan atribut dukungan LATEST, Anda harus mengupdate image Confidential Space setidaknya setiap bulan.

  • Jika Anda telah menetapkan kebijakan pengesahan yang memerlukan atribut dukungan STABLE, Anda harus mengupdate image Confidential Space setidaknya setiap enam bulan.

Anda dapat mempermudah pembuatan ulang VM menggunakan satu atau beberapa hal berikut:

Untuk mempelajari cara menyiapkan fitur ini, lihat Men-deploy workload Confidential Space dengan MIG menggunakan penskalaan otomatis, autohealing, dan update image.

Workload yang berjalan lama

Image Confidential Space mungkin tidak digunakan lagi atau dicabut selama workload yang berjalan lama. Jika Anda telah menetapkan kebijakan pengesahan untuk mewajibkan atribut dukungan Confidential Space STABLE dan image Confidential Space yang digunakan workload Anda tidak digunakan lagi atau dicabut, instance Confidential VM yang menjalankan workload tidak akan lulus pengesahan. Untuk menghindari gangguan, workload yang berjalan lama harus dirancang dengan mempertimbangkan kelanjutan, dan statusnya dikelola dengan aman.